Back to lessons

Hosting Operations

Check SQLite Database Integrity

You need a read-only integrity check for a SQLite database.

Command

sqlite3 app.db "PRAGMA integrity_check;"

What changed

Nothing changes. SQLite runs an integrity check and reports the result.

Danger

safe

When to use it

Use after crashes, disk issues, interrupted copies, or unexplained database errors.

When not to use it

Do not treat a passing result as a full application diagnosis; it only checks database structure.

Undo or recovery

No undo needed because this command is read-only.

Expected output

The word ok when the database passes the integrity check.

demo script

Disposable terminal steps

  1. ls -lh app.db
  2. sqlite3 app.db "PRAGMA integrity_check;"

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ ls -lh app.db
-rw-r--r-- 1 root root 16 Jun 25 13:19 app.db
::exit-code::0
$ sqlite3 app.db "PRAGMA integrity_check;"
ok
::exit-code::0

YouTube Short

Check SQLite integrity.

If a SQLite app gets weird after a crash, run PRAGMA integrity_check before chasing application code.

LinkedIn hook

When a SQLite-backed app behaves strangely, first rule out file corruption.

Question: Do you run integrity checks after SQLite-backed apps crash?

experiments

A/B tests to run

Metric: watch_time

A: Rule out corruption.

B: First check the file.