我的程序不断的往数据库里面插入数据,通过杀死进程的方法模拟程序异常退出。偶尔会产生日志文件-journal,此时我通过命令sqlite3打开数据库文件,然后退出命令,发现数据库文件变为0。按照官方文档介绍,-journal文件是产生在事务未完成时,出现应用崩溃,系统崩溃或者机器断电。
http://www.sqlite.org/fileformat.html#the_rollback_journal
If a transaction is aborted due to an application crash, an operating system crash, or a hardware power failure or crash, then the database may be left in an inconsistent state. The next time SQLite attempts to open the database file, the presence of the rollback journal file will be detected and the journal will be automatically played back to restore the database to its state at the start of the incomplete transaction.
等到下次打开数据库文件,会自动探测到日志文件,并恢复未完成的事务。这与我测试到的现象不符合啊!我对数据库并没有任何删除操作,再说删除条目数据库不一定不会变小。