To start a sqlite3 interactive session, invoke the sqlite3 command and optionally provide 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:
$ sqlite3mydata.db
SQLite version 3.43.0 2023-08-11 17:45:23
Enter ".help" for usage hints.
sqlite> createtablememos(text,priorityINTEGER);
sqlite> insertintomemosvalues('deliverprojectdescription',10);
sqlite> insertintomemosvalues('lunchwithChristine',100);
sqlite> select*frommemos;
deliver project description|10
lunch with Christine|100
sqlite>
If no database name is supplied, the ATTACH sql command can be used to attach to existing or create new
database files. ATTACH can also be used to attach to multiple databases within the same interactive
session. This is useful for migrating data between databases, possibly changing the schema along the
way.
Optionally, a SQL statement or set of SQL statements can be supplied as a single argument. Multiple
statements should be separated by semi-colons.
For example:
$ sqlite3-linemydata.db'select*frommemoswherepriority>20;'
text = lunch with Christine
priority = 100
SQLITEMETA-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, or perform administrative operations upon the attached
databases (such as rebuilding indices). Meta-commands are always prefixed with a dot (.).
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.