Reference: www.sqlite.org/sqlite.htmlIn sqlite3, we can run the ". Help" command to check all non-SQL commands. For example, Example 4:
SQLite>. Help. Help. Backup? DB? File backup dB (default "Main") to file. Bail On | off stop after hitting an error. Default off. Databases list names and files of attached databases. Dump? Table?... Dump the database in an SQL text format if Table specified, only dump tables matching like pattern table .. echo on | off turn command echo on or off. exit exit this program. explain? On | off? Turn output mode suitable for explain on or off. With no ARGs, it turns explain on... genfkey? Options? Options are: -- no-drop: Do not drop old fkey triggers. -- ignore-errors: Ignore tables with fkey errors -- Exec: Execute generated SQL immediately see file tool/genfkey. readme in the source distribution for further information .. header (s) on | off turn display of headers on or off. help show this message. import file table import data from file into table. indices? Table? Show names of all indices if Table specified, only show indices for tables matching like pattern table.. Load file? Entry? Load an extension library. Log File | off turn logging on or off. file can be stderr/stdout. Mode mode? Table? Set output mode where mode is one of: CSV comma-separated values Column left-aligned columns. (See. width) HTML <Table> code insert SQL insert statements for table line one value per line list values delimited. separator string tabs tab-separated values TCL list elements. nullvalue string print string in place of null values. output Filename send output to filename. output stdout send out Put to the screen. Prompt main continue Replace the standard prompts. Quit exit this program. Read filename Execute SQL in Filename. Restore? DB? File restore content of dB (default "Main") from file. schema? Table? Show the create statements if Table specified, only show tables matching like pattern table .. separator string change Separator Used by output mode and. Import. Show show the current values for various settings. tables? Table? List names of tables if Table specified, only list tables matching like pattern table .. timeout MS try opening locked tables for MS milliseconds. width num1 num2... set column widths for "column" mode. timer on | off turn the CPU timer Measurement on or offsqlite> sqlite3 can display the returned results in eight different ways:
"CSV
", "Column ",
"Html", "insert", "line ",
"List", "tabs", "TCL ".
You can set the display mode through. mode. The default value is "list". At this time, a record in the returned result shows a row. The content of each column is separated by a set delimiter. The default Delimiter is "| ". example 5: SQLite>. mode listsqlite> select * From tbl1; Hello | 10goodbye | 20 SQLite> you can use ". separator "to set the Separator in" list "mode. For example, if we want to use "," as the separator, we can: Example 6: SQLite>. separator "," SQLite> select * From tbl1; Hello, 10 goodbye, 20 SQLite> "line" mode, each row only displays one column of one row of the database. Each row is composed of column names, equal signs, and column values. Each record is separated by an empty row. For example, Example 7 SQLite>. Mode linesqlite> select * From tbl1; one = hellotwo = 10
One = goodbyetwo = 20 SQLite>
In column mode, each record is displayed in a single row. The first row shows the column name, the second row is only used to split the column name and record data, and the third row starts with the record content. For example, Example 8:
SQLite>. Mode Column
SQLite> select * From tbl1; one two ---------- Hello 10 goodbye 20 SQLite> by default, the width of each column can only display up to 10 characters. Therefore, if the data contains too many characters, it may not be displayed. However, we can use ". width" to set the width of each column. For example, Example 9: SQLite>. width 12 6 SQLite> select * From tbl1; one two ------------ Hello 10 goodbye 20 SQLite> Example 9 sets the width of column 1st and column 2 to 12 and 6 characters, respectively, the width of other columns is not changed. If you set the column width to 0, it is adjusted to the following three maximum values: 10, the number of characters in the column name, and the number of characters in the column in the first row. In this way, the column width can be automatically adjusted. The default column width is 0 so that it can be adjusted automatically. You can use the ". Header" command to set whether to display the header (the header includes the first line, column name, second line, and delimiter line ). For example, 10: SQLite>. header offsqlite> select * From tbl1; Hello 10 goodbye 20 SQLite> "insert" mode, the returned query results are displayed as SQL insert statements. For example, example 11: SQLite>. mode insert new_tablesqlite> select * From tbl1; insert into 'new _ table' values ('hello', 10); insert into 'new _ table' values ('Goodbye ', 20); SQLite> "html" mode, the returned results of the query are displayed in the form of XHTML table, which does not start with <Table> and </table>. However, each record starts with <tr> and ends with </tr>. The recorded data starts with <TD> and ends with </TD>. For example, example 12: SQLite> select * from system; <tr> <TD> 1 </TD> <TD> volume_music </TD> <TD> 7 </TD> </tr> <TD> 4 </ TD> <TD> volume_voice </TD> <TD> 4 </TD> </tr> ........ omitted ......... SQLite> ". the output command directs the output of the returned query results to a file. The first parameter of this command is the location to be targeted. After the output is directed to a file, you can use ". Output stdout" to redirect the output to the standard output. Example 13: SQLite>. Mode listsqlite>. Separator | SQLite>. Output test_file_1.txtsqlite> select * From tbl1; SQLite>. Exit $ cat test_file_1.txthello | 10goodbye | 20 $