SQLITE3(1)
๐ SQLITE3(1) โ a whole command line interface for SQLite version 3 ๐
okay so bestie, this is SQLITE3(1), living its best life over in the General Commands Manual section, and it's literally the command-line era of SQLite version 3. Sit down, grab a boba, we're doing this. ๐งโจ
โจ SYNOPSIS โจ
sqlite3 [options] [databasefile] [SQL]
that's it, that's the whole vibe check. ๐ซถ
๐ SUMMARY ๐
so sqlite3 is a terminal-based front-end to the SQLite library โ meaning it can evaluate queries interactively and show you the results in multiple formats. ๐
and it's not just for vibing at a prompt either: sqlite3 can also be used inside shell scripts and other applications to provide batch processing features. main character energy in a cron job, honestly. ๐
๐ฆ DESCRIPTION ๐ฆ
to start a sqlite3 interactive session, you just invoke the sqlite3 command and optionally hand it the name of a database file.
- if the database file does not exist, it will be created โจ
- if the database file does exist, it will be opened ๐
for example โ to create a new database file named mydata.db, create a table named memos, and insert a couple of records into that table:
$ sqlite3 mydata.db
SQLite version 3.43.0 2023-08-11 17:45:23
Enter ".help" for usage hints.
sqlite> create table memos(text, priority INTEGER);
sqlite> insert into memos values('deliver project description', 10);
sqlite> insert into memos values('lunch with Christine', 100);
sqlite> select * from memos;
deliver project description|10
lunch with Christine|100
sqlite>
look at her go. iconic. ๐
if no database name is supplied, the ATTACH sql command can be used to attach to existing or create new database files. and ATTACH can also be used to attach to multiple databases within the same interactive session โ which is super useful for migrating data between databases, possibly changing the schema along the way. lowkey a glow-up pipeline. ๐ซ
optionally, a SQL statement or set of SQL statements can be supplied as a single argument. multiple statements should be separated by semicolons.
for example:
$ sqlite3 -line mydata.db 'select * from memos where priority > 20;'
text = lunch with Christine
priority = 100
๐ช SQLITE META-COMMANDS ๐ช
the interactive interpreter offers a set of meta-commands that can be used to:
- control the output format ๐จ
- examine the currently attached database files ๐
- perform administrative operations upon the attached databases (such as rebuilding indices) ๐ ๏ธ
meta-commands are always prefixed with a dot (.). no cap.
a list of available meta-commands can be viewed at any time by issuing the .help command. for example:
sqlite> .help
the available commands differ by version and build options, so they are not listed here. please refer to your local copy for all available options. bestie, check your own house before you check mine. ๐
๐ธ INIT FILE ๐ธ
sqlite3 reads an initialization file to set the configuration of the interactive environment. throughout initialization, any previously specified setting can be overridden. the sequence of initialization is as follows:
- the default configuration is established as follows:
mode = LIST
separator = "|"
main prompt = "sqlite> "
continue prompt = " ...> "
- if the environment variable
XDG_CONFIG_HOMEis set then${XDG_CONFIG_HOME}/sqlite3/sqlitercis checked, else~/.config/sqlite3/sqlitercis checked. if the selected file does not exist then the fallback of~/.sqlitercis used. it should generally only contain meta-commands. - if the
-initoption is present, the specified file is processed. - all other command line options are processed.
that's the order, and it is not negotiable. periodt. ๐
๐ HISTORY FILE ๐
sqlite3 may be configured to use a history file to save SQL statements and meta-commands entered interactively. these statements and commands can be retrieved, edited, and reused at the main and continue prompts. so cute, so practical. ๐ซถ
- if the environment variable
SQLITE_HISTORYis set, it will be used as the name of the history file, whether it already exists or not. - if it is not set but the
XDG_STATE_HOMEenvironment variable is, then${XDG_STATE_HOME}/sqlite_historyis used. - if
XDG_STATE_HOMEis not set then~/.local/state/sqlite_historyis used. - if the selected file does not exist then
~/.sqlite_historywill be used as the history file.
if any history file is found, it will be written if the shell exits interactive mode normally, regardless of whether it existed previously โ though saving will silently fail if the history file's directory does not exist. like it'll just ghost you, quietly. ๐ญ no error, no note, nothing. bestie just make the directory, i'm begging. ๐
๐ฅ SEE ALSO ๐ฅ
https://sqlite.org/cli.htmlhttps://sqlite.org/fiddle(a WebAssembly build of the CLI app)- The
sqlite3-docpackage.
go read, go click, go slay. ๐
๐ AUTHOR ๐
this manual page was originally written by Andreas Rottmann <rotty@debian.org>, for the Debian GNU/Linux system (but may be used by others). it was subsequently revised by Bill Bumgarner <bbum@mac.com>, Laszlo Boszormenyi <gcs@debian.hu>, and the sqlite3 developers. absolute legends, every single one. ๐ซถโจ
and that's the page!! dated Fri Aug 11 23:50:12 CET 2023, from your girl SQLITE3(1) in the General Commands Manual. stay hydrated, back up your databases, and remember: .help is always there for you. bye bestie, ily, go write some queries ๐๐ฆ๐ธ๐
๐ฆ where this page comes from
- alpine 3.23: sqlite-doc 3.53.4-r0 ยท blessing
- alpine 3.24: sqlite-doc 3.53.4-r0 ยท blessing
- arch rolling: ruby-sqlite3 2.9.5-1 ยท BSD-3-Clause
- arch rolling: sqlite 3.54.0-1
- arch rolling: sqlite 3.54.1-1 ยท LicenseRef-Sqlite
- fedora 44: sqlite 3.51.2-1.fc44 ยท blessing
- fedora 44: sqlite 3.51.2-1.fc44 ยท blessing
- fedora 44: sqlite 3.51.2-2.fc44 ยท blessing
- fedora 44: sqlite 3.51.2-2.fc44 ยท blessing
- nixpkgs unstable: sqlite 3.53.3
- nixpkgs unstable: sqlite-interactive 3.53.3
- opensuse-leap 16.0: sqlite3 3.53.2-160000.1.1 ยท LicenseRef-SUSE-Public-Domain
- opensuse-leap 16.0: sqlite3 3.53.2-160000.1.1 ยท LicenseRef-SUSE-Public-Domain
- opensuse-leap 16.0: sqlite3 3.53.2-160000.1.1 ยท LicenseRef-SUSE-Public-Domain
- opensuse-leap 16.0: sqlite3 3.53.2-160000.1.1 ยท LicenseRef-SUSE-Public-Domain
- ubuntu stonking: sqlite3 3.53.4-2 ยท LicenseRef-public-domain
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms