Every now and then you need to check the integrity of an SQLite database. The command for this is:
sqlite>PRAGMA integrity_check;
This will either report the problems or just return “ok”
If it does report problems one solution I always try first is to do an export/import of the database:
>sqlite3 database.db sqlite>.output backup.db sqlite>.dump sqlite>.quit >sqlite3 database_fixed.db sqlite>.read backup.db sqlite>.quit >mv database_fixed.db database.db
This usually fix many of the common problems like “disk image is malformed” and “database is locked”
Tested on OSX 10.6.8 and SQLite v3.7.6 (MacPorts)
Comments are closed.