Skip to main content

Viewing Tables

Before querying data, you often need one quick answer: "What tables exist here?"

The .tables dot command gives you that answer instantly.

Core Concepts

flowchart LR
A[Open DB] --> B[Run .tables]
B --> C{Tables listed?}
C -->|Yes| D[Query known table names]
C -->|No| E[Check correct file with .databases]
CommandPurpose
.tablesList table/view names
.databasesConfirm active DB file

Code Examples

-- List table-like objects in current database.
.tables
Expected output
Space-separated table names, or blank if none exist.
-- If .tables appears empty, confirm you opened the intended file.
.databases
Expected output
Shows main path to currently open database.

SQLite-Specific Nuances

SQLite Nuance

.tables is a shell convenience command. Under the hood, metadata comes from SQLite's internal schema tables.

Common Pitfalls / Best Practices

Pitfall

Thinking "SQLite lost my tables" when .tables returns nothing.

Most often, you opened a different file path than expected.

Best Practice

Run .databases before and after switching files to avoid path confusion.

Quick Challenge

Open training.db, run .tables, then run .databases. What does each command tell you?

View Solution
  • .tables tells you object names in the current database.
  • .databases tells you which file is currently attached as main.