. and control the shell itself rather than querying the database. They do not require a trailing semicolon.
Quick reference
| Command | Description |
|---|---|
.help | Show the help message listing all available commands. |
.quit | Exit the shell. |
.exit [CODE] | Exit the shell with an optional return code. |
.open FILENAME [VFS] | Open (or create) a database file. |
.schema [TABLE] | Display the CREATE statement for a table or for all objects. |
.dump | Dump the entire database as SQL statements. |
.tables [PATTERN] | List tables, optionally filtered by a glob pattern. |
.databases | List attached databases. |
.mode MODE | Set the output mode (pretty, list, or line). |
.output [FILE] | Redirect output to a file, or back to stdout if no argument. |
.headers on|off | Show or hide column headers in list mode. |
.nullvalue VALUE | String to display in place of NULL in list mode. |
.echo on|off | Print each command before executing it. |
.show | Print the current values of all shell settings. |
.import [--csv] FILE TABLE | Import data from a CSV file into a table. |
.load PATH | Load a compiled extension library (.so / .dylib / .dll). |
.indexes [TABLE] | List indexes, optionally for a specific table. |
.stats [on|off] [-r] | Display or toggle execution statistics. -r resets after display. |
.timer on|off | Toggle query execution timing. |
.vfslist | List available VFS modules. |
.cd DIRECTORY | Change the shell working directory. |
.opcodes [NAME] | Show VDBE opcode descriptions, optionally filtered by name. |
.clone OUTPUT_FILE | Clone the open database to another file. |
.read FILE | Execute SQL statements from a file. |
.parameter set|list|clear | Manage named SQL parameter bindings. |
.manual [PAGE] | Display built-in manual pages. .man with no argument lists all pages. |
.dbtotxt [--page N] | Print raw database page contents as text. |
Database and file management
.open FILENAME [VFS]
Open or create a database file. If the file does not exist it is created.
.open :memory: to switch to an in-memory database within the same session.
.clone OUTPUT_FILE
Clone the currently open database to a new file without closing it.
.read FILE
Execute all SQL statements from a file.
Schema inspection
.schema [TABLE]
Display the CREATE statement for a table. Without an argument, shows all objects.
.tables [PATTERN]
List all tables. An optional glob pattern filters the results.
.indexes [TABLE]
List all indexes in the database. With a table name, shows only indexes for that table.
.databases
List all attached databases.
Data export
.dump
Dump the entire database as a sequence of SQL statements. Useful for backups or migrating data.
Data import
.import [--csv] FILE TABLE
Import data from a file into a table. Use --csv for CSV files.
Output mode
.mode MODE
Change how query results are displayed. Available modes:
| Mode | Description |
|---|---|
pretty | Bordered table with aligned columns (default). |
list | Pipe-separated values, matching SQLite’s default format. |
line | One column per line in name = value format. |
.headers on|off
Toggle column headers in list mode.
.nullvalue VALUE
Set the string printed in place of NULL in list mode.
.output [FILE]
Redirect query output to a file. Call .output with no argument to restore stdout.
Shell settings
.show
Print the current values of all shell settings.
.echo on|off
Print each command to stdout before executing it.
.timer on|off
Toggle timing output after each statement.
.stats [on|off] [-r]
Display execution statistics. Pass on or off to enable automatic stats after every query. The -r flag resets counters after displaying them.
.cd DIRECTORY
Change the shell’s current working directory.
Extensions and VFS
.load PATH
Load a compiled extension shared library.
.vfslist
List all available VFS (Virtual File System) modules.
Parameter bindings
.parameter set|list|clear
Manage named SQL parameter bindings for use in subsequent queries.
:name, @name, $name, ?1.
Diagnostics
.opcodes [NAME]
Show VDBE bytecode opcode descriptions. With no argument, lists all opcodes.
.dbtotxt [--page N]
Print raw database page contents as text. Use --page N to inspect a specific page number.
Built-in manual
.manual [PAGE]
Display built-in manual pages for specific features. Without an argument (or with .man), lists all available pages.
Exiting the shell
Use.quit or .exit to leave the shell. .exit CODE exits with a specific return code.
Ctrl-D (EOF) to exit, or press Ctrl-C twice to force quit.