如何检查的SQLite文件的一致性(健康检查) [英] How to check SQLite file consistency (health check)

查看:217
本文介绍了如何检查的SQLite文件的一致性(健康检查)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用我的Andr​​oid应用程序是从使用以下方法保存在文件夹中的资产几件创建一个SQLite数据库文件:
ReignDesign - Android应用程序中使用您自己的SQLite数据库

I am using a SQLite database file in my Android application that is created from several pieces stored in the assets folder by using the following approach: ReignDesign - Using your own SQLite database in Android applications

在assemby过程完成后,我想检查数据库是否被正确合并。以下方法可越过我的脑海:

On completion of the assemby process I would like to check if the database was correctly merged. The following approaches crossed my mind:


  • MD5哈希值进行比较

  • 检查表的存在和入境次数

哪种方法,你会建议?有没有更好的办法?

Which approach would you recommend? Is there a better way?

谢谢,

菲利普

推荐答案

我在我开发一个应用程序类似的情况。有各种各样的做这件事的方式;但最终我不再担心究竟是什么以及如何最好地衡量数据库的完整性,而是着重于'是我的数据库所使用的我的应用程序。

I had a similar situation in an application I'm developing. There are a variety of ways of doing it; but in the end I stopped worrying about what exactly and how to best measure database integrity, and instead focused on 'is my database usable by my application'.

所以基本上我测试是否:1)我可以打开SQLite数据库正常2)我可以对数据库执行查询和3)是否为pre定义的查询结果返回的期望是什么

So basically I test whether: 1) I can open the SQLite database properly 2) I can perform queries on the database and 3) Whether the result for a pre-defined query returns what is expected.

所以基本上:包括具有已知ID的记录,让你知道一个值的表,然后尝试读取该值。检查表计不能指望。

So basically: include a table with a record of known ID that gives a value that you know, then try to read that value. Checking the table count can't hope.

这是说,我在这里希望有人与DB系统的良好的知识将解释)正是 PRAGMA INTEGRITY_CHECK 确实和b)它是多么可靠,效率如何它与手动表检查进行比较。

That said I'm hoping someone here with a good knowledge of DB systems will explain a) exactly what PRAGMA integrity_check does and b) how reliable it is and how efficient it is compared with manual table checks.

这篇关于如何检查的SQLite文件的一致性(健康检查)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆