sqlite修复SQLite-database disk image is malformed

Main freelist: 3 of 3 pages missing from overflow list starting at 0

 

压缩

另一种更快的修补方法

扫除磁盘空间不够的缘由
修复步骤
$ sqlite3 backup.sqlite
sqlite> .output “_temp.tmp”
sqlite> .dump
sqlite> .quit
$ sqlite3 new.sqlite
sqlite> .read “_temp.tmp”
sqlite> .quit
就将错误的backup.sqlite修复为new.sqlite了

请参考  http://www.sqlite.org/faq.html#q21

sqlite> PRAGMA integrity_check;

*** in database main ***

运作某些SQL语句出错database disk image is malformed

sqlite3 newsfeed.db < newsfeed.sql

 

PHP使用popen调用sqlite shell来兑现修复

$handle = popen(“mv ../backup.sqlite bad.sqlite && sqlite3 bad.sqlite
.dump | sqlite3 good.sqlite && mv good.sqlite ../backup.sqlite”, ‘r’);
$read = fread($handle, 4096);
echo $read;
pclose($handle);

$echo “.dump” | sqlite3 old.db | sqlite3 new.db

sqlite3 newsfeed.db .dump > newsfeed.sql

sqlite,直接将 old.db 修复为 new.db

sqlite3 my.sqlite 'VACUUM;'

 

原文:http://zhiwei.li/text/2010/08/%e4%bf%ae%e5%a4%8dsqlite-database-disk-image-is-malformed/

http://www.sqlite.org/sqlite.html

注明SQLite的内部数据格式,已经毁损

或者

网站地图xml地图