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

NAME

6       sqlite - A command line interface for SQLite
7

SYNOPSIS

9       sqlite [options] filename [SQL]
10
11   SUMMARY
12       sqlite  is a terminal-based front-end to the SQLite library. It enables
13       you to type in queries interactively, issue them to SQLite and see  the
14       results.  Alternatively,  you can specify SQL code on the command-line.
15       In addition it provides a number of meta-commands.
16
17

DESCRIPTION

19       This manual page documents briefly the  sqlite  command.   This  manual
20       page  was  written  for  the  Debian GNU/Linux distribution because the
21       original program does not have a manual page.
22
23   GETTING STARTED
24       To start the sqlite program, just type "sqlite" followed  by  the  name
25       the  file that holds the SQLite database. If the file does not exist, a
26       new one is created automatically. The sqlite program will  then  prompt
27       you  to  enter SQL. Type in SQL statements (terminated by a semicolon),
28       press "Enter" and the SQL will be executed.
29
30       For example, to create a new SQLite database named "ex1" with a  single
31       table named "tbl1", you might do this:
32
33       $ sqlite ex1
34       SQLite version 2.0.0
35       Enter ".help" for instructions
36       sqlite> create table tbl1(one varchar(10), two smallint);
37       sqlite> insert into tbl1 values('hello!',10);
38       sqlite> insert into tbl1 values('goodbye', 20);
39       sqlite> select * from tbl1;
40       hello!|10
41       goodbye|20
42       sqlite>
43
44
45
46   SQLITE META-COMMANDS
47       Most  of  the time, sqlite just reads lines of input and passes them on
48       to the SQLite library for execution. But if an input line begins with a
49       dot  ("."), then that line is intercepted and interpreted by the sqlite
50       program itself. These "dot commands" are typically used to  change  the
51       output  format  of  queries,  or  to  execute certain prepackaged query
52       statements.
53
54       For a listing of the available dot commands, you can enter  ".help"  at
55       any time. For example:
56
57       sqlite> .help
58       .dump ?TABLE? ...      Dump the database in an text format
59       .echo ON|OFF           Turn command echo on or off
60       .exit                  Exit this program
61       .explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.
62                              "off" will revert to the output mode that was
63                              previously in effect
64       .header(s) ON|OFF      Turn display of headers on or off
65       .help                  Show this message
66       .indices TABLE         Show names of all indices on TABLE
67       .mode MODE             Set mode to one of "line(s)", "column(s)",
68                              "insert", "list", or "html"
69       .mode insert TABLE     Generate SQL insert statements for TABLE
70       .nullvalue STRING      Print STRING instead of nothing for NULL data
71       .output FILENAME       Send output to FILENAME
72       .output stdout         Send output to the screen
73       .prompt MAIN CONTINUE  Replace the standard prompts
74                              "sqlite > " and "   ...> "
75                              with the strings MAIN and CONTINUE
76                              CONTINUE is optional.
77       .quit                  Exit this program
78       .read FILENAME         Execute SQL in FILENAME
79       .reindex ?TABLE?       Rebuild indices
80       .schema ?TABLE?        Show the CREATE statements
81       .separator STRING      Change separator string for "list" mode
82       .show                  Show the current values for the following:
83                              .echo
84                              .explain
85                              .mode
86                              .nullvalue
87                              .output
88                              .separator
89                              .width
90       .tables ?PATTERN?      List names of tables matching a pattern
91       .timeout MS            Try opening locked tables for MS milliseconds
92       .width NUM NUM ...     Set column widths for "column" mode
93       sqlite>
94
95
96

OPTIONS

98       The program has the following options:
99
100       -init file
101              Read  in and process 'file', which contains "dot commands".  You
102              can use this file to initialize display settings.
103
104       -html  Set output mode to HTML.
105
106       -list  Set output mode to 'list'.
107
108       -line  Set output mode to 'line'.
109
110       -column
111              Set output mode to 'column'.
112
113       -separator separator
114              Specify which output field separator for  'list'  mode  to  use.
115              Default is '|'.
116
117       -nullvalue string
118              When  a  null  is  encountered,  print  'string'.  Default is no
119              string.
120
121       -[no]header
122              Turn headers on or off. Default is off.
123
124       -echo  Print commands before execution.
125
126
127

OUTPUT MODE

129       The SQLite program has different output modes, which define the way the
130       output (from queries) is formatted.
131
132       In  'list'  mode,  which is the default, one record per line is output,
133       each field separated by the separator  specified  with  the  -separator
134       option or .separator command.
135
136       In 'line' mode, each column is output on its own line, records are sep‐
137       arated by blank lines.
138
139       In HTML mode, an XHTML table is generated.
140
141       In 'column' mode, one record per line  is  output,  aligned  neatly  in
142       colums.
143
144

INIT FILE

146       sqlite  can  be initialized using resource files. These can be combined
147       with command line arguments to set up sqlite exactly the way  you  want
148       it.  Initialization proceeds as follows:
149
150       o The defaults of
151
152
153       mode            = LIST
154       separator       = "|"
155       main prompt     = "sqlite> "
156       continue prompt = "   ...> "
157
158
159       are established.
160
161       o  If a file .sqliterc can be found in the user's home directory, it is
162       read and processed. It should only contain "dot commands".  If the file
163       is  not found or cannot be read, processing continues without notifica‐
164       tion.
165
166       o If a file is specified on the command line with the -init option,  it
167       is processed in the same manner as .sqliterc
168
169       o All other command line options are processed
170
171       o The database is opened and you are now ready to begin.
172
173

SEE ALSO

175       http://www.hwaci.com/sw/sqlite/
176       The sqlite-doc package
177

AUTHOR

179       This   manual   page   was   originally  written  by  Andreas  Rottmann
180       <rotty@debian.org>, for the Debian GNU/Linux system (but may be used by
181       others).
182
183
184
185                           Mon Apr 15 23:49:17 2002                  SQLITE(1)
Impressum