牧羊岛

懒是不会有好果子吃滴//

导航

SQLite打开提示database disk image is malformed

Posted on 2013-11-22 11:44  牧羊岛  阅读(1747)  评论(0)    收藏  举报

SQLite打开提示database disk image is malformed

网上说产生这种错误的原因有很多种,磁盘空间不足,还有就是写入数据过程中突然掉电等。

这种情况,如果数据还可以导出,那么就可以修复

 

>sqlite Database_1.db
SQLite version 3.6.2
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .output “_temp.tmp”
sqlite> .dump
sqlite> .quit

>sqlite Database_1.new.db
SQLite version 3.6.2
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .read “_temp.tmp”
sqlite> .quit

还有更快的方法,我还没用过:

另一种更快的修复方法

$echo “.dump” | sqlite3 old.db | sqlite3 new.db
//直接将 old.db 修复为 new.db

或者

sqlite3 newsfeed.db .dump > newsfeed.sql
sqlite3 newsfeed.db < newsfeed.sql