运行某些sql语句出错database disk image is malformed
说明sqlite的内部数据格式,已经损坏
sqlite> PRAGMA integrity_check;
*** in database main ***
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了
另一种更快的修复方法
$echo “.dump” | sqlite3 old.db | sqlite3 new.db
直接将 old.db 修复为 new.db
或者
sqlite3 newsFeed.db .dump > newsFeed.sql
sqlite3 newsFeed.db < newsFeed.sql
请参考 http://www.sqlite.org/faq.html#q21
http://www.sqlite.org/sqlite.html
$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);
压缩
sqlite3 my.sqlite 'VACUUM;'
原文:http://www.cnblogs.com/adinet/archive/2011/11/03/2233858.html原文链接:https://www.f2er.com/sqlite/198445.html