linux – 如何验证SQLite db3文件是否有效/一致

我有一些sqlite版本3 db3文件我从一个实时运行的生产系统(我知道坏sysadmin坏sysadmin)复制出于各种原因.是否有一些我可以运行的sqlite命令将验证是否可以从这些文件中读取所有数据(我不介意它是否需要一段时间).

我正在考虑攻击一些转储所有数据然后将其重新导入新文件的perl.我认为如果遇到损坏的数据,sqlite将抛出异常.有没有更好的办法?

我是CentOS 5.3和sqlite-3.3.6-2

解决方法

我想你想试试:
pragma integrity_check;

documentation

This pragma does an integrity check of the entire database. The
integrity_check pragma looks for out-of-order records,missing pages,
malformed records,missing index entries,and UNIQUE and NOT NULL
constraint errors. If the integrity_check pragma finds problems,
strings are returned (as multiple rows with a single column per row)
which describe the problems. […]

See also the 07001 command which does most of the checking of PRAGMA integrity_check but runs much faster.

相关文章

linux常用进程通信方式包括管道(pipe)、有名管道(FIFO)、...
Linux性能观测工具按类别可分为系统级别和进程级别,系统级别...
本文详细介绍了curl命令基础和高级用法,包括跳过https的证书...
本文包含作者工作中常用到的一些命令,用于诊断网络、磁盘占满...
linux的平均负载表示运行态和就绪态及不可中断状态(正在io)的...
CPU上下文频繁切换会导致系统性能下降,切换分为进程切换、线...