Skip to main content

SQLite Dot Commands

Dot commands are CLI shortcuts for shell-level tasks like listing tables, showing schema, and changing output formatting.

They are essential for fast exploration while learning.

Core Concepts

flowchart TD
A[Need data?] --> B{SQL or shell task?}
B -->|Data query| C[Use SQL statement]
B -->|Shell/metadata| D[Use dot command]
Dot commandPurposeExample
.helpList available dot commands.help
.databasesShow attached DB files.databases
.tablesList tables/views.tables
.schemaShow CREATE statements.schema
.modeSet output mode.mode column
.headersShow/hide column names.headers on

Code Examples

-- Show shell help for dot commands.
.help
Expected output
A long list of available dot commands and descriptions.
-- Improve readability of query results.
.mode column
.headers on
SELECT 'Alice' AS name, 95 AS score;
namescore
Alice95

SQLite-Specific Nuances

SQLite Nuance

Dot commands are interpreted by sqlite3 itself.

If you send .tables through an application driver, it will fail because it is not SQL.

Common Pitfalls / Best Practices

Pitfall

Trying to run multiple dot commands in the middle of unfinished SQL input.

Finish or cancel SQL input first, then run dot commands.

Best Practice

Start each learning session with .headers on and .mode column so outputs are easier to read.

Quick Challenge

Set readable output and run a query that returns topic and level.

View Solution
.headers on
.mode column
SELECT 'CLI' AS topic, 'beginner' AS level;
topiclevel
CLIbeginner