SQLite shell application

Source: Internet
Author: User
Tags import database

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

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.