SQLite table structure and data import and export

Source: Internet
Author: User

Reprinted from: http://blog.csdn.net/shunzi19860518/article/details/5932782

======================================

 

Export all
Sqlite3 data. DB
>. Output dd. SQL
>. Dump

Import all
Sqlite3 mydb. DB
>. Read dd. SQL

Use the official sqlite3.exe tool to operate SQLite databases.
Go to management:
Sqlite3.exe D:/test. DB // assume the data is D:/test. DB
>. Databases // display show databases of all databases and MySQL;
>. Tables // display the table of the current database and the show tables of MySQL;
>. Schment tablename; // display the table structure and the show create table tbl_name of MySQL.
>. Output C: // 1. SQL // export the SQL statement of the current database and mysqldump of MySQL
>. Dump
>. Import C: // 1. SQL // import // source for MySQL
==============================
Import
Command:. Import
SQLite>. Import file name table name
Note 1: Do not forget the Starting Point
NOTE 2: This statement cannot end with a semicolon. Non-SQL statements do not need to end with a semicolon.
NOTE 3: You need to check the default separator. It must be consistent. Otherwise, the SQLite field may be incorrectly divided.
Run the. show command to view the delimiter. If the Delimiter is inconsistent, modify it directly, for example:
SQLite>. separator ","
Convert the separator into a comma.
Example 1:
Import the data in file a.csv into Table tab_xx. (fields in a.csv are separated by commas)
SQLite>. separator ","
SQLite>. Import a.csv tab_xx
SQLite>
Import is complete.

Export
Implementation Method: redirects the output to a file.
Command:. Output
SQLite>. Output a.txt
Then, enter an SQL statement to query the data to be exported. After the query, the data is not displayed on the screen and is directly written to the file.
Enter
SQLite>. Output stdout
Redirects the output to the screen.
Example 2:
Export the data in tab_xx to the a.txt file.
SQLite>. Output a.txt
SQLite> select * From tab_xx;
SQLite>. Output stdout
Export completed.

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.