Record Common commands and tips
Display records:
. Mode col
. Headers on
Select * from test limit 10
The above command will open the header and automatically typeset it, as shown below
Item_id tag
--------------------
-1 CSS
-2 CSS
-4 E-Ink
Get the auto-increment primary key value after insertion:
Select last_insert_rowid ();
Obtain the following data:
Last_insert_rowid ()
-------------------
3
Index operation:
Create:
Create index test_index on test ("name ");
Display:
. Indices Test
Obtain all tables in the database:
. Table
Or
Select * From sqlite_master where type = "table"
Output result to file:
. Output Filename. Log
The operations after this command are all written into the above files.
Export the entire database:
. Output Data
. Dump
Import database:
There are two ways to import data, which method determines the format of the file to be imported. If the file is composed of SQL statements, you can use the. read command to import (execute) the file. If the file is composed of values separated by commas (,) or other delimiters (,), you can use the. Import [Table] command. This command parses the specified file and tries to insert data into the specified table.
Back up a database using the command line:
You can directly back up data using the command line without entering the shell:
SQLite test. DB. Dump> dump
Restore
SQLite test. DB <dump