1 .\" Hey, EMACS: -*- nroff -*-
2 .\" First parameter, NAME, should be all caps
3 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
4 .\" other parameters are allowed: see man(7), man(1)
5 .TH SQLITE3 1 "Mon Jan 31 11:14:00 2014"
6 .\" Please adjust this date whenever revising the manpage.
8 .\" Some roff macros, for reference:
9 .\" .nh disable hyphenation
10 .\" .hy enable hyphenation
11 .\" .ad l left justify
12 .\" .ad b justify to both left and right margins
13 .\" .nf disable filling
14 .\" .fi enable filling
15 .\" .br insert line break
16 .\" .sp <n> insert n+1 empty lines
17 .\" for manpage-specific macros, see man(7)
20 \- A command line interface for SQLite version 3
31 is a terminal-based front-end to the SQLite library that can evaluate
32 queries interactively and display the results in multiple formats.
34 can also be used within shell scripts and other applications to provide
35 batch processing features.
40 interactive session, invoke the
42 command and optionally provide the name of a database file. If the
43 database file does not exist, it will be created. If the database file
44 does exist, it will be opened.
46 For example, to create a new database file named "mydata.db", create
47 a table named "memos" and insert a couple of records into that table:
54 Enter ".help" for instructions
57 .B create table memos(text, priority INTEGER);
60 .B insert into memos values('deliver project description', 10);
63 .B insert into memos values('lunch with Christine', 100);
66 .B select * from memos;
68 deliver project description|10
70 lunch with Christine|100
75 If no database name is supplied, the ATTACH sql command can be used
76 to attach to existing or create new database files. ATTACH can also
77 be used to attach to multiple databases within the same interactive
78 session. This is useful for migrating data between databases,
79 possibly changing the schema along the way.
81 Optionally, a SQL statement or set of SQL statements can be supplied as
82 a single argument. Multiple statements should be separated by
88 .B sqlite3 -line mydata.db 'select * from memos where priority > 20;'
90 text = lunch with Christine
96 .SS SQLITE META-COMMANDS
98 The interactive interpreter offers a set of meta-commands that can be
99 used to control the output format, examine the currently attached
100 database files, or perform administrative operations upon the
101 attached databases (such as rebuilding indices). Meta-commands are
102 always prefixed with a dot (.).
104 A list of available meta-commands can be viewed at any time by issuing
105 the '.help' command. For example:
111 .backup ?DB? FILE Backup DB (default "main") to FILE
112 .bail ON|OFF Stop after hitting an error. Default OFF
113 .databases List names and files of attached databases
114 .dump ?TABLE? ... Dump the database in an SQL text format
115 If TABLE specified, only dump tables matching
117 .echo ON|OFF Turn command echo on or off
118 .exit Exit this program
119 .explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.
120 With no args, it turns EXPLAIN on.
121 .header(s) ON|OFF Turn display of headers on or off
122 .help Show this message
123 .import FILE TABLE Import data from FILE into TABLE
124 .indices ?TABLE? Show names of all indices
125 If TABLE specified, only show indices for tables
126 matching LIKE pattern TABLE.
127 .load FILE ?ENTRY? Load an extension library
128 .log FILE|off Turn logging on or off. FILE can be stderr/stdout
129 .mode MODE ?TABLE? Set output mode where MODE is one of:
130 csv Comma-separated values
131 column Left-aligned columns. (See .width)
132 html HTML <table> code
133 insert SQL insert statements for TABLE
134 line One value per line
135 list Values delimited by .separator string
136 tabs Tab-separated values
137 tcl TCL list elements
138 .nullvalue STRING Use STRING in place of NULL values
139 .open ?FILENAME? Close existing database and reopen FILENAME
140 .output FILENAME Send output to FILENAME
141 .output stdout Send output to the screen
142 .print STRING... Print literal STRING
143 .prompt MAIN CONTINUE Replace the standard prompts
144 .quit Exit this program
145 .read FILENAME Execute SQL in FILENAME
146 .restore ?DB? FILE Restore content of DB (default "main") from FILE
147 .schema ?TABLE? Show the CREATE statements
148 If TABLE specified, only show tables matching
150 .separator STRING Change separator used by output mode and .import
151 .show Show the current values for various settings
152 .stats ON|OFF Turn stats on or off
153 .tables ?TABLE? List names of tables
154 If TABLE specified, only list tables matching
156 .timeout MS Try opening locked tables for MS milliseconds
157 .trace FILE|off Output each SQL statement as it is run
158 .vfsname ?AUX? Print the name of the VFS stack
159 .width NUM1 NUM2 ... Set column widths for "column" mode
160 .timer ON|OFF Turn the CPU timer measurement on or off
167 has the following options:
170 Stop after hitting an error.
176 Query results will be displayed in a table like form, using
177 whitespace characters to separate the columns and align the
186 Set output mode to CSV (comma separated values).
189 Print commands before execution.
192 Read and execute commands from
194 , which can contain a mix of SQL statements and meta-commands.
197 Turn headers on or off.
200 Show help on options and exit.
203 Query results will be output as simple HTML tables.
206 Force interactive I/O.
209 Query results will be displayed with one value per line, rows
210 separated by a blank line. Designed to be easily parsed by
211 scripts or other programs
214 Query results will be displayed with the separator (|, by default)
215 character between each field value. The default.
218 Set default mmap size to
222 .BI \-nullvalue\ string
223 Set string used to represent NULL values. Default is ''
226 .BI \-separator\ separator
227 Set output field separator. Default is '|'.
230 Print memory stats before each finalize.
243 reads an initialization file to set the configuration of the
244 interactive environment. Throughout initialization, any previously
245 specified setting can be overridden. The sequence of initialization is
248 o The default configuration is established as follows:
255 main prompt = "sqlite> "
256 continue prompt = " ...> "
263 exists, it is processed first.
264 can be found in the user's home directory, it is
265 read and processed. It should generally only contain meta-commands.
267 o If the -init option is present, the specified file is processed.
269 o All other command line options are processed.
272 http://www.sqlite.org/
274 The sqlite3-doc package.
276 This manual page was originally written by Andreas Rottmann
277 <rotty@debian.org>, for the Debian GNU/Linux system (but may be used
278 by others). It was subsequently revised by Bill Bumgarner <bbum@mac.com> and
279 further updated by Laszlo Boszormenyi <gcs@debian.hu> .