Hosting Operations
Read-onlyCheck SQLite Database Integrity
You need a read-only integrity check for a SQLite database.
Command
sqlite3 app.db "PRAGMA integrity_check;"
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not treat a passing result as a full application diagnosis; it only checks database structure.
Expected output
The word ok when the database passes the integrity check.
System impact
Read-only. Nothing changes. SQLite runs an integrity check and reports the result.
Recovery / rollback: no state is changed.
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.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ ls -lh app.db
-rw-r--r-- 1 root root 16 Jun 26 00:27 app.db
$ sqlite3 app.db "PRAGMA integrity_check;"
ok
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
ls -lh app.dbsqlite3 app.db "PRAGMA integrity_check;"
next steps
Related commands
Show Indexes on a SQLite Table
Slow lookups often start with missing or misunderstood indexes.
sqlite3 app.db "PRAGMA index_list('orders');"
Back Up a SQLite Database File
Copying a live SQLite file blindly can produce a bad backup.
sqlite3 app.db ".backup backup/app.db"
Count SQLite Events by Type
A noisy event type stands out faster when you group it.
sqlite3 app.db "SELECT event_type, count(*) FROM events GROUP BY event_type ORDER BY count(*) DESC;"
Show Recent SQLite Events
For small apps, the quickest timeline may be inside the SQLite file.
sqlite3 app.db "SELECT created_at, event_type FROM events ORDER BY created_at DESC LIMIT 5;"
Count Rows in Key SQLite Tables
A quick row count can reveal empty imports, runaway events, or missing data.
sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Study mapping
Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.
Useful for
- LPIC-1 style command-line practice
- LFCS style performance tasks
- Linux+ style troubleshooting review
Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.