Some useful SQLite commands are summarized, and sqlite commands are useful.
Display table structure:
Copy codeThe Code is as follows:
Sqlite>. schema [table]
Obtain all tables and views:
Copy codeThe Code is as follows:
Sqlite>. tables
Obtain the index list of the specified table:
Copy codeThe Code is as follows:
Sqlite>. indices [table]
Export the database to an SQL file:
Copy codeThe Code is as follows:
Sqlite>. output [filename]
Sqlite>. dump
Sqlite>. output stdout
Import a database from an SQL file:
Copy codeThe Code is as follows:
Sqlite>. read [filename]
Format output data to CSV format:
Copy codeThe Code is as follows:
Sqlite>. output plugin filename.csv]
Sqlite>. separator,
Sqlite> select * from test;
Sqlite>. output stdout
Import data from a CSV file to a table:
Copy codeThe Code is as follows:
Sqlite> create table newtable (id integer primary key, value text );
Sqlite>. import into filename.csv] newtable
Back up the database:
Copy codeThe Code is as follows:
/* Usage: sqlite3 [database]. dump> [filename] */
Sqlite3 mytable. db. dump> backup. SQL
Restore database:
Copy codeThe Code is as follows:
/* Usage: sqlite3 [database] <[filename] */
Sqlite3 mytable. db <backup. SQL