Back to lessons

Hosting Operations

List SQLite User Tables Only

You need to list normal tables from sqlite_master.

Command

sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"

What changed

Nothing changes. The command queries sqlite_master for table names.

Danger

safe

When to use it

Use when .tables output is too compact or you need a script-friendly list.

When not to use it

Do not use it to list indexes or views without changing the type filter.

Undo or recovery

No undo needed because this command is read-only.

Expected output

One table name per line, sorted by name.

demo script

Disposable terminal steps

  1. sqlite3 app.db ".tables"
  2. sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ sqlite3 app.db ".tables"
events  orders  schema_migrations  users
::exit-code::0
$ sqlite3 app.db "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
users
orders
events
schema_migrations
::exit-code::0

YouTube Short

Script-friendly table list.

Query sqlite_master when you want table names one per line instead of compact dot tables output.

LinkedIn hook

System metadata tables can distract from the app tables you care about.

Question: Do you prefer .tables or sqlite_master when scripting SQLite checks?

experiments

A/B tests to run

Metric: comment_rate

A: .tables is quick.

B: sqlite_master is scriptable.