sqlite3
databaseLinux/Unix
The sqlite3 command is one of the most frequently used commands in Linux/Unix-like operating systems. sqlite3 Command-line interface for SQLite 3 databases
Quick Reference
Command Name:
sqlite3
Category:
database
Platform:
Linux/Unix
Basic Usage:
sqlite3 [options] [arguments]
Common Use Cases
Syntax
sqlite3 [options] [database] [SQL statements]
Options
Option | Description |
---|---|
-append |
Append to output file instead of overwriting |
-ascii |
Set output mode to 'ascii' |
-batch |
Force batch I/O |
-column |
Set output mode to 'column' |
-cmd COMMAND |
Run COMMAND before reading stdin |
-csv |
Set output mode to 'csv' |
-echo |
Echo commands before execution |
-header |
Turn on column headers |
-help |
Show help message |
-html |
Set output mode to HTML |
-init FILENAME |
Read/process named file |
-interactive |
Force interactive I/O |
-json |
Set output mode to 'json' |
-line |
Set output mode to 'line' |
-list |
Set output mode to 'list' |
-markdown |
Set output mode to 'markdown' |
-newline SEP |
Set output row separator (default: \n) |
-noheader |
Turn off column headers |
-nullvalue TEXT |
Set text string for NULL values |
-separator SEP |
Set output column separator (default: |) |
-stats |
Print memory stats before each finalize |
-table |
Set output mode to 'table' |
-version |
Show SQLite version |
Dot Commands | Description |
---|---|
.backup ?DB? FILE |
Backup database to FILE |
.databases |
List names and files of attached databases |
.dump ?TABLE? |
Dump database as SQL text |
.exit |
Exit this program |
.headers on|off |
Turn display of headers on or off |
.import FILE TABLE |
Import data from FILE into TABLE |
.indices ?TABLE? |
Show names of indexes |
.mode MODE |
Set output mode (csv, column, html, insert, line, list, tabs, tcl) |
.open ?FILENAME? |
Close existing database and open FILENAME |
.output FILENAME |
Send output to FILENAME |
.quit |
Exit this program |
.read FILENAME |
Execute SQL in FILENAME |
.restore ?DB? FILE |
Restore content of DB from FILE |
.schema ?TABLE? |
Show the CREATE statements |
.separator STRING |
Change separator for CSV and column modes |
.tables ?PATTERN? |
List names of tables matching PATTERN |
Examples
How to Use These Examples
The examples below show common ways to use the sqlite3
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
sqlite3 database.db