SQLite User Forum

Does PRAGMA integrity_check detect missing rows?
Login

Does PRAGMA integrity_check detect missing rows?

(1) By anonymous on 2022-09-11 22:37:32 [link] [source]

Suppose my database gets corrupted (suppose I have some bad RAM): will PRAGMA integrity_check report missing rows?

I have read in the SQLite documentation that integrity_check will check the indices for missing entries, but a missing entry in an index only means that an existing row does not have a corresponding entry in the index, it doesn't mean that a missing row has an entry in an index (which is what would be required to detect a missing row).

So, simple question: Does PRAGMA integrity_check detect missing rows?

(2.2) By Sunny Saini (SunnySaini_com) on 2022-09-12 12:32:55 edited from 2.1 in reply to 1 [source]

I guess yes.

Create a new db with exactly one table with minimal columns say, two.

Fill few rows.

Create index on one column.

Exit SQLite.

Open the db file in a hex editor. Table can be located somewhere at the mid and index at the end of the database file.

You may now experiment by corrupting table data or index data in overwrite mode in the hex editor.