Skip to content

Running an Integrity Check

Chris Locke edited this page Jun 14, 2023 · 1 revision

Note: See the official SQLite documentation on the integrity check here: https://www.sqlite.org/pragma.html


A database consists of records, and indexes that point to these records. If DB4S crashes during an operation (for example, while adding or deleting records) then the database could become corrupted.

This section is only relevant if you use the normal (default) journal modes. For all journal modes, see this page: https://www.sqlite.org/pragma.html

image

In the same directory where the database lives, should be a journal file. This is usually the same name as the database file, prefixed with '-journal'.

image

If you open a database where the journal file already exists (either due to another DB4S instance or application making amendments to the database or a previous session) you'll receive the above "Could not open database file" warning. If another instance is not running and the journal file was from a previously crashed session, then you can attempt to delete the journal file.
Warning This is not a recommended method. Depending on what was happening at the time of the crash, the database is in an unknown state. Ideally, you should revert to a known good backup.

To confirm if the database is at least consistent with the records and internal indexes, we can run an 'integrity check'. This is only a check - if it does find an error, it's not like chkdsk in DOS which corrects any errors. Errors can only be corrected by reverting to an earlier backup copy.

Perform an integrity check

image

A database has to be opened. You cannot perform an integrity check on a database that cannot be opened.

Click 'Tools' and then 'Integrity check'.

image

A message will appear asking you to confirm, with the opportunity to visit the official SQLite documentation.

image

After confirming the dialog, a new SQL tab will be opened and the command 'pragma integrity_check' will be executed. The result of this command will be shown in the results pane.

Clone this wiki locally