blob: e35358ec617307c4c42cd0f53afcb0533ecd333c [file] [log] [blame]
drh3a88fbd2002-01-07 19:58:43 +00001.\" 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)
persicom45698a32002-04-18 02:53:54 +00005.TH SQLITE 1 "Mon Apr 15 23:49:17 2002"
drh3a88fbd2002-01-07 19:58:43 +00006.\" Please adjust this date whenever revising the manpage.
7.\"
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)
18.SH NAME
19sqlite \- A command line interface for SQLite
20.SH SYNOPSIS
21.B sqlite
22.RI [ options ] " filename " [ SQL ]
23.SS SUMMARY
24.PP
25sqlite is a terminal-based front-end to the SQLite library. It enables
drh0fface62002-05-06 11:34:26 +000026you to type in queries interactively, issue them to SQLite and see the
27results. Alternatively, you can specify SQL code on the command-line. In
drh3a88fbd2002-01-07 19:58:43 +000028addition it provides a number of meta-commands.
29
30.SH DESCRIPTION
31This manual page documents briefly the
32.B sqlite
33command.
34This manual page was written for the Debian GNU/Linux distribution
35because the original program does not have a manual page.
36.SS GETTING STARTED
37.PP
38To start the sqlite program, just type "sqlite" followed by the name
39the file that holds the SQLite database. If the file does not exist, a
40new one is created automatically. The sqlite program will then prompt
41you to enter SQL. Type in SQL statements (terminated by a semicolon),
42press "Enter" and the SQL will be executed.
43
44For example, to create a new SQLite database named "ex1" with a single
45table named "tbl1", you might do this:
46.sp
47.nf
48$ sqlite ex1
49SQLite version 2.0.0
50Enter ".help" for instructions
51sqlite> create table tbl1(one varchar(10), two smallint);
52sqlite> insert into tbl1 values('hello!',10);
53sqlite> insert into tbl1 values('goodbye', 20);
54sqlite> select * from tbl1;
55hello!|10
56goodbye|20
57sqlite>
58.sp
59.fi
60
61.SS SQLITE META-COMMANDS
62.PP
63Most of the time, sqlite just reads lines of input and passes them on
64to the SQLite library for execution. But if an input line begins with
65a dot ("."), then that line is intercepted and interpreted by the
66sqlite program itself. These "dot commands" are typically used to
67change the output format of queries, or to execute certain prepackaged
68query statements.
69
70For a listing of the available dot commands, you can enter ".help" at
71any time. For example:
72.sp
73.nf
74.cc |
75sqlite> .help
persicom45698a32002-04-18 02:53:54 +000076.dump ?TABLE? ... Dump the database in an text format
77.echo ON|OFF Turn command echo on or off
drh3a88fbd2002-01-07 19:58:43 +000078.exit Exit this program
persicom45698a32002-04-18 02:53:54 +000079.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
80 "off" will revert to the output mode that was
81 previously in effect
82.header(s) ON|OFF Turn display of headers on or off
drh3a88fbd2002-01-07 19:58:43 +000083.help Show this message
84.indices TABLE Show names of all indices on TABLE
persicom45698a32002-04-18 02:53:54 +000085.mode MODE Set mode to one of "line(s)", "column(s)",
86 "insert", "list", or "html"
drh3a88fbd2002-01-07 19:58:43 +000087.mode insert TABLE Generate SQL insert statements for TABLE
persicom45698a32002-04-18 02:53:54 +000088.nullvalue STRING Print STRING instead of nothing for NULL data
drh3a88fbd2002-01-07 19:58:43 +000089.output FILENAME Send output to FILENAME
90.output stdout Send output to the screen
persicom45698a32002-04-18 02:53:54 +000091.prompt MAIN CONTINUE Replace the standard prompts
92 "sqlite > " and " ...> "
93 with the strings MAIN and CONTINUE
94 CONTINUE is optional.
95.quit Exit this program
96.read FILENAME Execute SQL in FILENAME
97.reindex ?TABLE? Rebuild indices
drh3a88fbd2002-01-07 19:58:43 +000098.schema ?TABLE? Show the CREATE statements
99.separator STRING Change separator string for "list" mode
persicom45698a32002-04-18 02:53:54 +0000100.show Show the current values for the following:
101 .echo
102 .explain
103 .mode
104 .nullvalue
105 .output
106 .separator
107 .width
108.tables ?PATTERN? List names of tables matching a pattern
drh3a88fbd2002-01-07 19:58:43 +0000109.timeout MS Try opening locked tables for MS milliseconds
110.width NUM NUM ... Set column widths for "column" mode
111sqlite>
112|cc .
113.sp
114.fi
115
116.SH OPTIONS
117The program has the following options:
118.TP
persicom45698a32002-04-18 02:53:54 +0000119.BI \-init\ file
120Read in and process 'file', which contains "dot commands".
121You can use this file to initialize display settings.
122.TP
drh3a88fbd2002-01-07 19:58:43 +0000123.B \-html
124Set output mode to HTML.
125.TP
126.B \-list
127Set output mode to 'list'.
128.TP
129.B \-line
130Set output mode to 'line'.
131.TP
persicom45698a32002-04-18 02:53:54 +0000132.B \-column
133Set output mode to 'column'.
134.TP
drh0fface62002-05-06 11:34:26 +0000135.BI \-separator\ separator
136Specify which output field separator for 'list' mode to use.
drh3a88fbd2002-01-07 19:58:43 +0000137Default is '|'.
persicom45698a32002-04-18 02:53:54 +0000138.TP
139.BI \-nullvalue\ string
140When a null is encountered, print 'string'. Default is no string.
141.TP
142.B \-[no]header
143Turn headers on or off. Default is off.
144.TP
145.B \-echo
146Print commands before execution.
147
drh3a88fbd2002-01-07 19:58:43 +0000148
149.SH OUTPUT MODE
150The SQLite program has different output modes, which define the way
151the output (from queries) is formatted.
152
153In 'list' mode, which is the default, one record per line is output,
drh0fface62002-05-06 11:34:26 +0000154each field separated by the separator specified with the
155\fB-separator\fP option or \fB.separator\fP command.
drh3a88fbd2002-01-07 19:58:43 +0000156
157In 'line' mode, each column is output on its own line, records are
drh0fface62002-05-06 11:34:26 +0000158separated by blank lines.
drh3a88fbd2002-01-07 19:58:43 +0000159
160In HTML mode, an XHTML table is generated.
161
162In 'column' mode, one record per line is output, aligned neatly in colums.
163
persicom45698a32002-04-18 02:53:54 +0000164.SH INIT FILE
165sqlite can be initialized using resource files. These can be combined with
166command line arguments to set up sqlite exactly the way you want it.
167Initialization proceeds as follows:
168
169o The defaults of
170
171.sp
172.nf
173.cc |
174mode = LIST
175separator = "|"
176main prompt = "sqlite> "
177continue prompt = " ...> "
178|cc .
179.sp
180.fi
181
182are established.
183
184o If a file .sqliterc can be found in the user's home directory, it is
185read and processed. It should only contain "dot commands". If the
186file is not found or cannot be read, processing continues without
187notification.
188
189o If a file is specified on the command line with the -init option, it
190is processed in the same manner as .sqliterc
191
192o All other command line options are processed
193
194o The database is opened and you are now ready to begin.
195
drh3a88fbd2002-01-07 19:58:43 +0000196.SH SEE ALSO
197http://www.hwaci.com/sw/sqlite/
198.br
199The sqlite-doc package
200.SH AUTHOR
drh0fface62002-05-06 11:34:26 +0000201This manual page was originally written by Andreas Rottmann
202<rotty@debian.org>, for the Debian GNU/Linux system (but may be used
203by others).