]> git.ipfire.org Git - thirdparty/sqlite.git/blame - sqlite3.1
Fix a problem with queries that use "IN(...) ORDER BY ... NULLS LAST" or similar...
[thirdparty/sqlite.git] / sqlite3.1
CommitLineData
3a88fbda 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)
6c6badd2 5.TH SQLITE3 1 "Fri Aug 11 23:50:12 CET 2023"
3a88fbda 6.\" 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
75308731 19.B sqlite3
20\- A command line interface for SQLite version 3
21
3a88fbda 22.SH SYNOPSIS
75308731 23.B sqlite3
24.RI [ options ]
25.RI [ databasefile ]
26.RI [ SQL ]
27
28.SH SUMMARY
3a88fbda 29.PP
75308731 30.B sqlite3
31is a terminal-based front-end to the SQLite library that can evaluate
32queries interactively and display the results in multiple formats.
33.B sqlite3
34can also be used within shell scripts and other applications to provide
35batch processing features.
3a88fbda 36
37.SH DESCRIPTION
75308731 38To start a
39.B sqlite3
40interactive session, invoke the
41.B sqlite3
42command and optionally provide the name of a database file. If the
43database file does not exist, it will be created. If the database file
44does exist, it will be opened.
45
46For example, to create a new database file named "mydata.db", create
47a table named "memos" and insert a couple of records into that table:
3a88fbda 48.sp
75308731 49$
50.B sqlite3 mydata.db
51.br
6c6badd2 52SQLite version 3.43.0 2023-08-11 17:45:23
75308731 53.br
6c6badd2 54Enter ".help" for usage hints.
75308731 55.br
56sqlite>
57.B create table memos(text, priority INTEGER);
58.br
59sqlite>
60.B insert into memos values('deliver project description', 10);
61.br
62sqlite>
63.B insert into memos values('lunch with Christine', 100);
64.br
65sqlite>
66.B select * from memos;
67.br
68deliver project description|10
69.br
70lunch with Christine|100
71.br
3a88fbda 72sqlite>
73.sp
75308731 74
75If no database name is supplied, the ATTACH sql command can be used
76to attach to existing or create new database files. ATTACH can also
77be used to attach to multiple databases within the same interactive
78session. This is useful for migrating data between databases,
79possibly changing the schema along the way.
80
81Optionally, a SQL statement or set of SQL statements can be supplied as
82a single argument. Multiple statements should be separated by
83semi-colons.
84
85For example:
86.sp
87$
88.B sqlite3 -line mydata.db 'select * from memos where priority > 20;'
89.br
90 text = lunch with Christine
91.br
92priority = 100
93.br
94.sp
3a88fbda 95
96.SS SQLITE META-COMMANDS
97.PP
75308731 98The interactive interpreter offers a set of meta-commands that can be
99used to control the output format, examine the currently attached
100database files, or perform administrative operations upon the
101attached databases (such as rebuilding indices). Meta-commands are
102always prefixed with a dot (.).
103
104A list of available meta-commands can be viewed at any time by issuing
105the '.help' command. For example:
3a88fbda 106.sp
75308731 107sqlite>
108.B .help
3a88fbda 109.nf
0fb5daed 110.tr %.
6c6badd2 111...
3a88fbda 112.sp
113.fi
6c6badd2 114
115The available commands differ by version and build options, so they
116are not listed here. Please refer to your local copy for all available
117options.
3a88fbda 118
3a88fbda 119
45698a3a 120.SH INIT FILE
75308731 121.B sqlite3
122reads an initialization file to set the configuration of the
123interactive environment. Throughout initialization, any previously
124specified setting can be overridden. The sequence of initialization is
125as follows:
45698a3a 126
75308731 127o The default configuration is established as follows:
45698a3a 128
129.sp
130.nf
131.cc |
132mode = LIST
133separator = "|"
134main prompt = "sqlite> "
135continue prompt = " ...> "
136|cc .
137.sp
138.fi
139
6c6badd2 140o If the file
141.B ${XDG_CONFIG_HOME}/sqlite3/sqliterc
142or
75308731 143.B ~/.sqliterc
6c6badd2 144exists, the first of those to be found is processed during startup.
145It should generally only contain meta-commands.
45698a3a 146
75308731 147o If the -init option is present, the specified file is processed.
45698a3a 148
75308731 149o All other command line options are processed.
45698a3a 150
3a88fbda 151.SH SEE ALSO
6c6badd2 152https://sqlite.org/cli.html
153.br
154https://sqlite.org/fiddle (a WebAssembly build of the CLI app)
3a88fbda 155.br
d49c5459 156The sqlite3-doc package.
3a88fbda 157.SH AUTHOR
0fface6e 158This manual page was originally written by Andreas Rottmann
159<rotty@debian.org>, for the Debian GNU/Linux system (but may be used
6c6badd2 160by others). It was subsequently revised by Bill Bumgarner <bbum@mac.com>,
161Laszlo Boszormenyi <gcs@debian.hu>, and the sqlite3 developers.