integrity_check — Initiate a database file integrity verification

Common Usage

PRAGMA [database.]integrity_check;
PRAGMA [database.]integrity_chcek( max_errors );


The integrity_check pragma runs a self-check on the database structure. The check runs through a battery of tests that verify the integrity of the database file, its structure, and its contents. Errors are returned as text descriptions in a single-column table. At most, max_errors are reported before the integrity check aborts. By default, max_errors is 100.

If no errors are found, a single row consisting of the text value ok will be returned.

Unfortunately, if an error is found, there is typically very little that can be done to fix it. Although you may be able to extract some of the data, it is best to have regular dumps or backups.

See Also


Get Using SQLite now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.