Some useful SQLite commands are summarized, and sqlite commands are useful.

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.