sqlite3 报错提示:
database disk image is malformed |
看提示意思是指数据库的数据文件格式发生异常,所以数据查询和写入不正常,在网上google了一些文章,找到了一个解决方法。
一般来说,sqlite3的数据文件发生这个问题,想直接修复数据是行不通了,
在进入sqlite3后的命令行中,运行以下命令:
PRAGMA integrity_check*** in database main ***On tree page 120611 cell 0: 3 of 4 pages missing from overflow list starting at 120617On tree page 120616 cell 0: 3 of 4 pages missing from overflow list starting at 120621On tree page 3309 cell 0: 3 of 4 pages missing from over |
假设原数据库名: abc.db
运行命令:
sqlite3 abc.db.output "data.sql".dump.quit |
再建个新数据库 abcd.db
sqlite3 abcd.db |
然后
.read "data.sql".quit |
最后修复原来的数据库名和文件权限。