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]
| Command | Purpose |
|---|---|
.tables | List table/view names |
.databases | Confirm 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
.tablestells you object names in the current database..databasestells you which file is currently attached asmain.