CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
sqlite3.1182 linesDownload Raw Back to root
1.\"                                      Hey, EMACS: -*- nroff -*-2.\" First parameter, NAME, should be all caps3.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection4.\" other parameters are allowed: see man(7), man(1)5.TH SQLITE3 1 "Fri Aug 11 23:50:12 CET 2023"6.\" Please adjust this date whenever revising the manpage.7.\"8.\" Some roff macros, for reference:9.\" .nh        disable hyphenation10.\" .hy        enable hyphenation11.\" .ad l      left justify12.\" .ad b      justify to both left and right margins13.\" .nf        disable filling14.\" .fi        enable filling15.\" .br        insert line break16.\" .sp <n>    insert n+1 empty lines17.\" for manpage-specific macros, see man(7)18.SH NAME19.B sqlite3 20\- A command line interface for SQLite version 321 22.SH SYNOPSIS23.B sqlite324.RI [ options ]25.RI [ databasefile ]26.RI [ SQL ]27 28.SH SUMMARY29.PP30.B sqlite331is a terminal-based front-end to the SQLite library that can evaluate32queries interactively and display the results in multiple formats.33.B sqlite334can also be used within shell scripts and other applications to provide35batch processing features.36 37.SH DESCRIPTION38To start a39.B sqlite340interactive session, invoke the41.B sqlite342command and optionally provide the name of a database file.  If the43database file does not exist, it will be created.  If the database file44does exist, it will be opened.45 46For example, to create a new database file named "mydata.db", create47a table named "memos" and insert a couple of records into that table:48.sp49$ 50.B sqlite3 mydata.db51.br52SQLite version 3.43.0 2023-08-11 17:45:2353.br54Enter ".help" for usage hints.55.br56sqlite>57.B create table memos(text, priority INTEGER);58.br59sqlite>60.B insert into memos values('deliver project description', 10);61.br62sqlite>63.B insert into memos values('lunch with Christine', 100);64.br65sqlite>66.B select * from memos;67.br68deliver project description|1069.br70lunch with Christine|10071.br72sqlite>73.sp74 75If no database name is supplied, the ATTACH sql command can be used76to attach to existing or create new database files.  ATTACH can also77be used to attach to multiple databases within the same interactive78session.  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 as82a single argument.  Multiple statements should be separated by83semi-colons.84 85For example:86.sp87$ 88.B sqlite3 -line mydata.db 'select * from memos where priority > 20;'89.br90    text = lunch with Christine91.br92priority = 10093.br94.sp95 96.SS SQLITE META-COMMANDS97.PP98The interactive interpreter offers a set of meta-commands that can be99used to control the output format, examine the currently attached100database files, or perform administrative operations upon the101attached databases (such as rebuilding indices).   Meta-commands are102always prefixed with a dot (.).103 104A list of available meta-commands can be viewed at any time by issuing105the '.help' command.  For example:106.sp107sqlite>108.B .help109.nf110.tr %.111...112.sp113.fi114 115The available commands differ by version and build options, so they116are not listed here. Please refer to your local copy for all available117options.118 119 120.SH INIT FILE121.B sqlite3122reads an initialization file to set the configuration of the123interactive environment.  Throughout initialization, any previously124specified setting can be overridden.  The sequence of initialization is125as follows:126 127o The default configuration is established as follows:128 129.sp130.nf131.cc |132mode            = LIST133separator       = "|"134main prompt     = "sqlite> "135continue prompt = "   ...> "136|cc .137.sp138.fi139 140o If the environment variable XDG_CONFIG_HOME is set then141.B ${XDG_CONFIG_HOME}/sqlite3/sqliterc142is checked, else143.B ~/.config/sqlite3/sqliterc144is checked. If the selected file does not exist then the fallback of145.B ~/.sqliterc146is used. It should generally only contain meta-commands.147 148o If the -init option is present, the specified file is processed.149 150o All other command line options are processed.151 152.SH HISTORY FILE153.B sqlite3154may be configured to use a history file to save SQL statements and155meta-commands entered interactively. These statements and commands can be156retrieved, edited and, reused at the main and continue prompts. If the157environment variable158.B SQLITE_HISTORY159is set, it will be used as the name of the history file, whether it160already exists or not. If it is not set but the XDG_STATE_HOME161environment variable is then162.B ${XDG_STATE_HOME}/sqlite_history163is used. If XDG_STATE_HOME is not set then164.B ~/.local/state/sqlite_history165is used. If the selected file does not exist then166.B ~/.sqlite_history167will be used as the history file. If any history file is found, it168will be written if the shell exits interactive mode normally,169regardless of whether it existed previously, though saving will170silently fail if the history file's directory does not exist.171.SH SEE ALSO172https://sqlite.org/cli.html173.br174https://sqlite.org/fiddle (a WebAssembly build of the CLI app)175.br176The sqlite3-doc package.177.SH AUTHOR178This manual page was originally written by Andreas Rottmann179<rotty@debian.org>, for the Debian GNU/Linux system (but may be used180by others). It was subsequently revised by Bill Bumgarner <bbum@mac.com>,181Laszlo Boszormenyi <gcs@debian.hu>, and the sqlite3 developers.182