您的位置:首页 > 数据库

修复SQLite-database disk image is malformed

2017-04-25 14:39 288 查看
运行某些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.sqlitesqlite> .output “_temp.tmp”sqlite> .dumpsqlite> .quit$ sqlite3 new.sqlitesqlite> .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.sqlsqlite3 newsfeed.db < newsfeed.sql请参考  http://www.sqlite.org/faq.html#q21http://www.sqlite.org/sqlite.htmlPHP使用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);  压缩
sqlite3 my.sqlite 'VACUUM;'
原文:http://www.cnblogs.com/adinet/archive/2011/11/03/2233858.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android sqlite