質問

I am looking for a command line utility to validate SQLite databases. I ran into a situation in some inherited code where an application fails to startup because an attempt to access a database produced the following error:

database disk image is malformed

So I need to instrument some validation code in the application. Additionally, though, I need a tool that I can run from the Linux prompt to tell me simply if the database is corrupt or not.

Thanks

役に立ちましたか?

解決

You can do something like this:

sqlite3 database.db "PRAGMA integrity_check"

他のヒント

You can use PRAGMA integrity_check on the database.

If the Database is corrupted you can use this SQLite command:

cd $DATABASE_LOCATION
echo '.dump'|sqlite3 $DB_NAME|sqlite3 new_repaired_$DB_NAME
mv $DB_NAME corrupt_$DB_NAME
mv new_repaired_$DB_NAME $DB_NAME
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top