Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: 3332a164b330852926747c6b2934da9f889c1696 [file] [log] [blame]
drh3a88fbd2002-01-07 19:58:431.\" 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)
stephan6c6badd2023-08-11 22:40:065.TH SQLITE3 1 "Fri Aug 11 23:50:12 CET 2023"
drh3a88fbd2002-01-07 19:58:436.\" 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
drh75308732005-02-24 04:51:5119.B sqlite3
20\- A command line interface for SQLite version 3
21
drh3a88fbd2002-01-07 19:58:4322.SH SYNOPSIS
drh75308732005-02-24 04:51:5123.B sqlite3
24.RI [ options ]
25.RI [ databasefile ]
26.RI [ SQL ]
27
28.SH SUMMARY
drh3a88fbd2002-01-07 19:58:4329.PP
drh75308732005-02-24 04:51:5130.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.
drh3a88fbd2002-01-07 19:58:4336
37.SH DESCRIPTION
drh75308732005-02-24 04:51:5138To 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.
drh3a88fbd2002-01-07 19:58:4345
drh75308732005-02-24 04:51:5146For example, to create a new database file named "mydata.db", create
47a table named "memos" and insert a couple of records into that table:
drh3a88fbd2002-01-07 19:58:4348.sp
drh75308732005-02-24 04:51:5149$
50.B sqlite3 mydata.db
51.br
stephan6c6badd2023-08-11 22:40:0652SQLite version 3.43.0 2023-08-11 17:45:23
drh75308732005-02-24 04:51:5153.br
stephan6c6badd2023-08-11 22:40:0654Enter ".help" for usage hints.
drh75308732005-02-24 04:51:5155.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
drh3a88fbd2002-01-07 19:58:4372sqlite>
73.sp
drh75308732005-02-24 04:51:5174
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
drh3a88fbd2002-01-07 19:58:4395
96.SS SQLITE META-COMMANDS
97.PP
drh75308732005-02-24 04:51:5198The 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 (.).
drh3a88fbd2002-01-07 19:58:43103
drh75308732005-02-24 04:51:51104A list of available meta-commands can be viewed at any time by issuing
105the '.help' command. For example:
drh3a88fbd2002-01-07 19:58:43106.sp
drh75308732005-02-24 04:51:51107sqlite>
108.B .help
drh3a88fbd2002-01-07 19:58:43109.nf
drh0fb5dae2014-10-31 14:46:51110.tr %.
stephan6c6badd2023-08-11 22:40:06111...
drh3a88fbd2002-01-07 19:58:43112.sp
113.fi
stephan6c6badd2023-08-11 22:40:06114
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.
persicom45698a32002-04-18 02:53:54118
drh3a88fbd2002-01-07 19:58:43119
persicom45698a32002-04-18 02:53:54120.SH INIT FILE
drh75308732005-02-24 04:51:51121.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:
persicom45698a32002-04-18 02:53:54126
drh75308732005-02-24 04:51:51127o The default configuration is established as follows:
persicom45698a32002-04-18 02:53:54128
129.sp
130.nf
131.cc |
132mode = LIST
133separator = "|"
134main prompt = "sqlite> "
135continue prompt = " ...> "
136|cc .
137.sp
138.fi
139
stephan2752d132025-06-30 15:21:46140o If the environment variable XDG_CONFIG_HOME is set then
stephan6c6badd2023-08-11 22:40:06141.B ${XDG_CONFIG_HOME}/sqlite3/sqliterc
stephan2752d132025-06-30 15:21:46142is checked, else
143.B ~/.local/config/sqlite3/sqliterc
144is checked. If the selected file does not exist then the fallback of
drh75308732005-02-24 04:51:51145.B ~/.sqliterc
stephan2752d132025-06-30 15:21:46146is used. It should generally only contain meta-commands.
persicom45698a32002-04-18 02:53:54147
drh75308732005-02-24 04:51:51148o If the -init option is present, the specified file is processed.
persicom45698a32002-04-18 02:53:54149
drh75308732005-02-24 04:51:51150o All other command line options are processed.
persicom45698a32002-04-18 02:53:54151
stephan2752d132025-06-30 15:21:46152.SH HISTORY FILE
153.B sqlite3
154may be configured to use a history file to save SQL statements and
155meta-commands entered interactively. These statements and commands can be
156retrieved, edited and, reused at the main and continue prompts. If the
157environment variable
158.B SQLITE_HISTORY
159is set, it will be used as the name of the history file, whether it
160already exists or not. If it is not set but the XDG_STATE_HOME
161environment variable is then
162.B ${XDG_STATE_HOME}/sqlite_history
163is used. If XDG_STATE_HOME is not set then
164.B ~/.local/state/sqlite_history
165is used. If the selected file does not exist then
166.B ~/.sqlite_history
167will be used as the history file. If any history file is found, it
168will be written if the shell exits interactive mode normally,
169regardless of whether it existed previously, though saving will
170silently fail if the history file's directory does not exist.
drh3a88fbd2002-01-07 19:58:43171.SH SEE ALSO
stephan6c6badd2023-08-11 22:40:06172https://sqlite.org/cli.html
173.br
174https://sqlite.org/fiddle (a WebAssembly build of the CLI app)
drh3a88fbd2002-01-07 19:58:43175.br
drhd49c5452014-01-31 11:50:20176The sqlite3-doc package.
drh3a88fbd2002-01-07 19:58:43177.SH AUTHOR
drh0fface62002-05-06 11:34:26178This manual page was originally written by Andreas Rottmann
179<[email protected]>, for the Debian GNU/Linux system (but may be used
stephan6c6badd2023-08-11 22:40:06180by others). It was subsequently revised by Bill Bumgarner <[email protected]>,
181Laszlo Boszormenyi <[email protected]>, and the sqlite3 developers.