You are on page 1of 1

sqlite3 Cheat Sheet

by Richard Holloway (richardjh) via cheatography.com/478/cs/370/

sqlite3 Meta Commands sqlite3 Meta Commands contd. sqlite3 Options

.backup ?DB? FILE .schema ?TABLE? -init file


Backup DB (default "main") to FILE Show the CREATE statements Read and execute commands from file , which can

.bail ON|OFF .separator STRING contain a mix of SQL statements and meta-comm

Stop after hitting an error. Default OFF Change separator used by output mode and ands.

.databases .import -echo

List names and files of attached databases .show Print commands before execution.

.dump ?TABLE? ... Show the current values for various settings -[no]header
Turn headers on or off.
Dump the database in an SQL text format. .stats ON|OFF

.echo ON|OFF Turn stats on or off -bail

Turn command echo on or off .tables ?TABLE? Stop after hitting an error.

List names of tables -interactive


.exit
Exit this program .timeout MS Force interactive I/O .

.explain ?ON|OFF? Try opening locked tables for MS milliseconds -batch


Force batch I/O .
Turn output mode suitable for EXPLAIN on or off. .width NUM1 NUM2 ...

.header(s) ON|OFF Set column widths for "column" mode -column

Turn display of headers on or off .timer ON|OFF Query results will be displayed in a table like form,
using whitespace characters to separate the
.help Turn the CPU timer measurement on or off
columns and align the output.
Shows this information.
sqlite3 See Also -csv
.import FILE TABLE
Set output mode to CSV (comma separated
Import data from FILE into TABLE http://www.sqlite.org/
values).
.indices ?TABLE? The sqlite3-doc package.
-html
Show names of all indices
Query results will be output as simple HTML tables.
.load FILE ?ENTRY?
-line
Load an extension library
Query results will be displayed with one value per
.log FILE|off line, rows separated by a blank line. Designed to
Turn logging on or off. FILE can be stderr/stdout be easily parsed by scripts or other programs

.mode MODE ?TABLE? -list


Set output mode where MODE is one of: csv, Query results will be displayed with the separator (|,
column, html, insert, line, list, tabs, tcl by default) character between each field value. The
.nullvalue STRING default.
Print STRING in place of NULL values -separator separator
.output FILENAME Set output field separator. Default is '|'.

Send output to FILENAME -stats


.output stdout Print memory stats before each finalize.

Send output to the screen -nullvalue string

.prompt MAIN CONTINUE Set string used to represent NULL values. Default
Replace the standard prompts is '' (empty string).

.quit -version
Exit this program Show SQLite version.

.read FILENAME -vfs name


Execute SQL in FILENAME Use name as the default VFS .

.restore ?DB? FILE -help

Restore content of DB (default "main") from FILE Show help on options and exit.

Cheatographer Cheat Sheet Sponsor

Richard Holloway (richardjh) This cheat sheet was published on 13th May, 2012 FeedbackFair, increase your conversion rate today!
cheatography.com/richardjh/ and was last updated on 13th May, 2012. Try it free!
richardjh.org http://www.FeedbackFair.com

You might also like