SQLITE_CORRUPT: database disk image is malformed
SQLite found the database file's structure damaged. Stop writing to it, take a copy, and recover what you can with the .recover command or from a backup.
- Result code
SQLITE_CORRUPT- Name
11- Category
- Primary result codes
What it means
SQLITE_CORRUPT (11) means SQLite read something in the file that doesn't fit its format: a broken page, a bad pointer, an index entry with no matching row. SQLite doesn't corrupt files on its own in normal use; the SQLite documentation ("How To Corrupt An SQLite Database File") lists what does: files copied while a transaction is open, broken file locking (often on network file systems), deleting a hot journal, hardware or storage faults, and writes into the file by other code.
SQLITE_CORRUPT_INDEX is a special case where only an index is damaged and REINDEX may fix it.
Common causes
- Copying or backing up the database file while it was being written, or copying it without its
-walfile. - Deleting a
-journalor-walfile left after a crash. - A network file system or container volume with unreliable locking, letting two writers in at once.
- Disk, memory or power failures, or a storage layer that ignores fsync.
- Another part of the program writing to the file directly through an open file descriptor.
How to fix it
-
Stop writing to the database and make a copy of the file and any
-waland-journalfiles before you try anything. -
Measure the damage.
PRAGMA integrity_check;
-
If only indexes are affected, rebuild them.
REINDEX;
-
Otherwise recover the data into a new file with the
sqlite3shell's.recovercommand, then check the result:sqlite3 broken.db .recover | sqlite3 recovered.db. -
Restore from a backup if the recovery is incomplete, and make future backups with
VACUUM INTOor the backup API rather than copying the file while it is in use.VACUUM INTO '/backups/app-2026-11-09.db';
Related errors
SQLITE_NOTADBfile is not a databaseSQLITE_IOERRdisk I/O errorSQLITE_BUSYdatabase is locked824SQL Server: Logical consistency-based I/O error
More primary result codes errors
SQLITE_ERRORSQL logic errorSQLITE_PERMaccess permission deniedSQLITE_ABORTquery abortedSQLITE_LOCKEDdatabase table is lockedSQLITE_NOMEMout of memorySQLITE_READONLYattempt to write a readonly databaseSQLITE_INTERRUPTinterruptedSQLITE_FULLdatabase or disk is full
The code and message text are from the SQLite result and error codes documentation. Browse the full SQLite error list or search every database error.
Work on SQLite in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQLite and the other databases you use.