Display table structure:
Copy the codeThe code is as follows:
sqlite> .schema [table]
Get all tables and views:
Copy the codeThe code is as follows:
sqlite > .tables
Get the index list of the specified table:
Copy the codeThe code is as follows:
sqlite > .indices [table ]
Export the database to SQL file:
Copy the codeThe code is as follows:
sqlite > .output [filename ]
sqlite > .dump
sqlite > .output stdout
Importing a database from a SQL file:
Copy the codeThe code is as follows:
sqlite > .read [filename ]
Format output data to CSV format:
Copy the codeThe code is as follows:
sqlite >.output [ ]
sqlite >.separator ,
sqlite > select * from test;
sqlite >.output stdout
Import data from a CSV file into a table:
Copy the codeThe code is as follows:
sqlite >create table newtable ( id integer primary key, value text );
sqlite >.import [ ] newtable
Backup the database:
Copy the codeThe code is as follows:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 .dump >
Recover the database:
Copy the codeThe code is as follows:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 <