Hosting Operations
Read-onlyCount Rows in Key SQLite Tables
You need row counts for several important SQLite tables in one command.
Command
sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
Before you run this
System impact: Read-only. Low when scoped to the shown target.
When not to use it: Do not run huge counts blindly on very large production databases without understanding cost.
Expected output
Pipe-separated table names and row counts.
System impact
Read-only. Nothing changes. The command reads row counts from selected tables.
Recovery / rollback: no state is changed.
When to use it
Use during data sanity checks, imports, restores, or incident triage.
When not to use it
Do not run huge counts blindly on very large production databases without understanding cost.
Watch this command run
Command transcript
This sanitized transcript shows the commands and output shape without exposing host details.
$ sqlite3 app.db ".tables"
events orders schema_migrations users
$ sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
users|4
orders|7
events|12
View commands shown
These are the commands shown in the sanitized transcript.
Commands shown
sqlite3 app.db ".tables"sqlite3 app.db "SELECT 'users', count(*) FROM users UNION ALL SELECT 'orders', count(*) FROM orders UNION ALL SELECT 'events', count(*) FROM events;"
next steps
Related commands
Find Duplicate Emails in SQLite
Duplicate account data is easier to spot with one grouped query.
sqlite3 app.db "SELECT email, count(*) FROM users GROUP BY email HAVING count(*) > 1;"
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;"
List SQLite User Tables Only
System metadata tables can distract from the app tables you care about.
sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
Show Indexes on a SQLite Table
Slow lookups often start with missing or misunderstood indexes.
sqlite3 app.db "PRAGMA index_list('orders');"
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.