1SQLITE3(1)                  General Commands Manual                 SQLITE3(1)
2
3
4

NAME

6       sqlite3 - A command line interface for SQLite version 3
7
8

SYNOPSIS

10       sqlite3 [options] [databasefile] [SQL]
11
12

SUMMARY

14       sqlite3  is  a  terminal-based front-end to the SQLite library that can
15       evaluate queries interactively and display the results in multiple for‐
16       mats.  sqlite3 can also be used within shell scripts and other applica‐
17       tions to provide batch processing features.
18
19

DESCRIPTION

21       To start a sqlite3 interactive session, invoke the sqlite3 command  and
22       optionally  provide  the name of a database file.  If the database file
23       does not exist, it will be created.  If the database file  does  exist,
24       it will be opened.
25
26       For  example, to create a new database file named "mydata.db", create a
27       table named "memos" and insert a couple of records into that table:
28
29       $ sqlite3 mydata.db
30       SQLite version 3.8.8
31       Enter ".help" for instructions
32       sqlite> create table memos(text, priority INTEGER);
33       sqlite> insert into memos values('deliver project description', 10);
34       sqlite> insert into memos values('lunch with Christine', 100);
35       sqlite> select * from memos;
36       deliver project description|10
37       lunch with Christine|100
38       sqlite>
39
40
41       If no database name is supplied, the ATTACH sql command can be used  to
42       attach  to  existing  or create new database files.  ATTACH can also be
43       used to attach to multiple databases within the same  interactive  ses‐
44       sion.   This  is  useful for migrating data between databases, possibly
45       changing the schema along the way.
46
47       Optionally, a SQL statement or set of SQL statements can be supplied as
48       a  single  argument.   Multiple statements should be separated by semi-
49       colons.
50
51       For example:
52
53       $ sqlite3 -line mydata.db 'select * from memos where priority > 20;'
54           text = lunch with Christine
55       priority = 100
56
57
58
59   SQLITE META-COMMANDS
60       The interactive interpreter offers a set of meta-commands that  can  be
61       used to control the output format, examine the currently attached data‐
62       base files, or perform  administrative  operations  upon  the  attached
63       databases (such as rebuilding indices).   Meta-commands are always pre‐
64       fixed with a dot (.).
65
66       A list of available meta-commands can be viewed at any time by  issuing
67       the '.help' command.  For example:
68
69       sqlite> .help
70       .backup ?DB? FILE      Backup DB (default "main") to FILE
71       .bail on|off           Stop after hitting an error.  Default OFF
72       .clone NEWDB           Clone data into NEWDB from the existing database
73       .databases             List names and files of attached databases
74       .dump ?TABLE? ...      Dump the database in an SQL text format
75                                If TABLE specified, only dump tables matching
76                                LIKE pattern TABLE.
77       .echo on|off           Turn command echo on or off
78       .eqp on|off            Enable or disable automatic EXPLAIN QUERY PLAN
79       .exit                  Exit this program
80       .explain ?on|off?      Turn output mode suitable for EXPLAIN on or off.
81                                With no args, it turns EXPLAIN on.
82       .fullschema            Show schema and the content of sqlite_stat tables
83       .headers on|off        Turn display of headers on or off
84       .help                  Show this message
85       .import FILE TABLE     Import data from FILE into TABLE
86       .indices ?TABLE?       Show names of all indices
87                                If TABLE specified, only show indices for tables
88                                matching LIKE pattern TABLE.
89       .load FILE ?ENTRY?     Load an extension library
90       .log FILE|off          Turn logging on or off.  FILE can be stderr/stdout
91       .mode MODE ?TABLE?     Set output mode where MODE is one of:
92                                csv      Comma-separated values
93                                column   Left-aligned columns.  (See .width)
94                                html     HTML <table> code
95                                insert   SQL insert statements for TABLE
96                                line     One value per line
97                                list     Values delimited by .separator string
98                                tabs     Tab-separated values
99                                tcl      TCL list elements
100       .nullvalue STRING      Use STRING in place of NULL values
101       .once FILENAME         Output for the next SQL command only to FILENAME
102       .open ?FILENAME?       Close existing database and reopen FILENAME
103       .output ?FILENAME?     Send output to FILENAME or stdout
104       .print STRING...       Print literal STRING
105       .prompt MAIN CONTINUE  Replace the standard prompts
106       .quit                  Exit this program
107       .read FILENAME         Execute SQL in FILENAME
108       .restore ?DB? FILE     Restore content of DB (default "main") from FILE
109       .save FILE             Write in-memory database into FILE
110       .schema ?TABLE?        Show the CREATE statements
111                                If TABLE specified, only show tables matching
112                                LIKE pattern TABLE.
113       .separator STRING ?NL? Change separator used by output mode and .import
114                                NL is the end-of-line mark for CSV
115       .shell CMD ARGS...     Run CMD ARGS... in a system shell
116       .show                  Show the current values for various settings
117       .stats on|off          Turn stats on or off
118       .system CMD ARGS...    Run CMD ARGS... in a system shell
119       .tables ?TABLE?        List names of tables
120                                If TABLE specified, only list tables matching
121                                LIKE pattern TABLE.
122       .timeout MS            Try opening locked tables for MS milliseconds
123       .timer on|off          Turn SQL timer on or off
124       .trace FILE|off        Output each SQL statement as it is run
125       .vfsname ?AUX?         Print the name of the VFS stack
126       .width NUM1 NUM2 ...   Set column widths for "column" mode
127                                Negative values right-justify
128       sqlite>
129
130

OPTIONS

132       sqlite3 has the following options:
133
134       -bail  Stop after hitting an error.
135
136       -batch Force batch I/O.
137
138       -column
139              Query  results  will  be  displayed  in a table like form, using
140              whitespace characters to separate the columns and align the out‐
141              put.
142
143       -cmd command
144              run command before reading stdin
145
146       -csv   Set output mode to CSV (comma separated values).
147
148       -echo  Print commands before execution.
149
150       -init file
151              Read and execute commands from file , which can contain a mix of
152              SQL statements and meta-commands.
153
154       -[no]header
155              Turn headers on or off.
156
157       -help  Show help on options and exit.
158
159       -html  Query results will be output as simple HTML tables.
160
161       -interactive
162              Force interactive I/O.
163
164       -line  Query results will be displayed with one value  per  line,  rows
165              separated  by  a  blank  line.   Designed to be easily parsed by
166              scripts or other programs
167
168       -list  Query results will  be  displayed  with  the  separator  (|,  by
169              default) character between each field value.  The default.
170
171       -mmap N
172              Set default mmap size to N
173
174       -nullvalue string
175              Set  string used to represent NULL values.  Default is '' (empty
176              string).
177
178       -separator separator
179              Set output field separator.  Default is '|'.
180
181       -stats Print memory stats before each finalize.
182
183       -version
184              Show SQLite version.
185
186       -vfs name
187              Use name as the default VFS.
188
189
190

INIT FILE

192       sqlite3 reads an initialization file to set the  configuration  of  the
193       interactive  environment.   Throughout  initialization,  any previously
194       specified setting can be overridden.  The sequence of initialization is
195       as follows:
196
197       o The default configuration is established as follows:
198
199
200       mode            = LIST
201       separator       = "|"
202       main prompt     = "sqlite> "
203       continue prompt = "   ...> "
204
205
206       o  If the file ~/.sqliterc exists, it is processed first.  can be found
207       in the user's home directory, it is read and processed.  It should gen‐
208       erally only contain meta-commands.
209
210       o If the -init option is present, the specified file is processed.
211
212       o All other command line options are processed.
213
214

SEE ALSO

216       http://www.sqlite.org/cli.html
217       The sqlite3-doc package.
218

AUTHOR

220       This   manual   page   was   originally  written  by  Andreas  Rottmann
221       <rotty@debian.org>, for the Debian GNU/Linux system (but may be used by
222       others).  It  was subsequently revised by Bill Bumgarner <bbum@mac.com>
223       and further updated by Laszlo Boszormenyi <gcs@debian.hu> .
224
225
226
227                         Fri Oct 31 10:41:31 EDT 2014               SQLITE3(1)
Impressum