UPDATE: There is now an automatic method that is built into SQLite: .recover
Sometimes, the corruption is only or mostly in indexes, in which case it would be possible to get some or most records by trying to dump the entire database with .dump
, and use those commands to create a new database:
$ sqlite3 mydata.db ".dump" | sqlite3 new.db
However, this is not always possible.
The easiest and most reliable way is to restore the database file from the backup.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…