SQLite打开提示database disk image is malformed

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

原文地址:https://www.cnblogs.com/ShepherdIsland/p/SQLite_database_disk_image_is_malformed.html