LoginSignup
20
18

More than 5 years have passed since last update.

破損したSQLiteのファイルを修復する

Last updated at Posted at 2016-09-27

概要

  • Adobe AIR製のWindowsアプリのデータ保存にSQLiteを使用していたら、データ容量が異様に肥大化している事案が発生(通常の10倍くらいに!)
  • SQLite Browser( http://sqlitebrowser.org/ )で開くとデータが表示できない。
  • PupSQLite( http://www.vector.co.jp/soft/winnt/business/se449564.html )で開くといくつかのテーブルで「database disk image is malformed」エラー
  • どうやら、データが破損しているらしい!

データ修復

SQLite本家からコマンドラインツールを取得
http://www.sqlite.org/download.html
いろいろあるが、Windowsなら「sqlite-tools-win32-x86-3140200.zip」をダウンロードする。
※記事作成時点の最新ファイル名なので、そのときの最新版を入手してください。

ファイルを展開し、コマンドプロンプト(またはPowerShell)で該当フォルダ―までたどり着き、以下コマンドを実行

sqlite3 mydata.db .dump | sqlite3 mydata_new.db

上記で 無事データ修復できました。
必ず修復できるわけではないと思いますが、どなたかの参考となれば。

参考

http://q.hatena.ne.jp/1258638989
http://taichino.com/engineer-life/database/4123

20
18
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
18