SQLite Commands
This chapter explains the simple yet useful commands used by SQLite programmers. These commands are called SQLite dot commands, and what makes them different is that they do not end with a semicolon ;.
Let's type a simple sqlite3 command at the command prompt; at the SQLite command prompt, you can use various SQLite commands.
$ sqlite3
SQLite version 3.3.6
Enter ".help" for instructions
sqlite>
To get a list of available dot commands, you can type ".help" at any time. For example:
sqlite>.help
The above command displays a list of various important SQLite dot commands, as shown below:
| Command | Description |
|---|---|
| .backup ?DB? FILE | Back up the DB database (default is "main") to the FILE. |
| .bail ON|OFF | Stop after an error occurs. Default is OFF. |
| .databases | List the names of databases and the files they are attached to. |
| .dump ?TABLE? | Dump the database in SQL text format. If TABLE is specified, only dump the TABLE tables matching the LIKE pattern. |
| .echo ON|OFF | Turn the echo command on or off. |
| .exit | Exit the SQLite prompt. |
| .explain ON|OFF | Turn the output mode suitable for EXPLAIN on or off. If no argument is given, it is EXPLAIN on, i.e., EXPLAIN is enabled. |
| .header(s) ON|OFF | Turn header display on or off. |
| .help | Show messages. |
| .import FILE TABLE | Import data from the FILE into the TABLE. |
| .indices ?TABLE? | Show the names of all indexes. If TABLE is specified, only show indexes for TABLE tables matching the LIKE pattern. |
| .load FILE ?ENTRY? | Load an extension library. |
| .log FILE|off | Turn logging on or off. The FILE can be stderr (standard error) / stdout (standard output). |
| .mode MODE | Set the output mode; MODE can be one of the following:
|
csv Comma-separated values
column Left-aligned columns
html The HTML