SQLite出现database disk image is malformed(11)的处理

前端之家收集整理的这篇文章主要介绍了SQLite出现database disk image is malformed(11)的处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

sqlite有一个很严重的缺点就是不提供Repair命令。
导致死亡提示database disk image is malformed
它的产生有很多种可能,比如,磁盘空间不足,还有就是写入数据过程中突然掉电等。
官方对产生原因的一些说明: http://www.sqlite.org/lockingv3.html#how_to_corrupt

  1. sqlite my.sqlite3
  2. sqlite>PRAGMA integrity_check;

获得提示

  1. *** in database main ***
  2. Page 1518: btreeInitPage() returns error code 11
  3. On tree page 1566 cell 2: Child page depth differs
  4. On tree page 1566 cell 3: Child page depth differs
  5. sql error: database disk image is malformed

可以尝试通过简单的导出导入方式对损坏的库文件回复
首先导出数据

  1. sqlite3 my.sqlite3
  2. sqlite>.output tmp.sql
  3. sqlite>.dump
  4. sqlite>.quit

再倒入到一个新库中

  1. sqlite3 mynew.sqlite3
  2. sqlite>.read tmp.sql
  3. sqlite>.quit

这时新建的mynew.sqlite3一般可用。

原文地址:http://www.sunnyu.com/?p=201

猜你在找的Sqlite相关文章