SQLite 3 import and export data to txt or CSV files

Source: Internet
Author: User

 

 

you can use the official sqlite3.exe tool to operate SQLite databases on the Internet.
go to management:
sqlite3.exe D: \ test. DB // assume that 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 MySQL show create table tbl_name
. output C: \\\\ 1. SQL // export the SQL statement of the current database and MySQL mysqldump
. dump
. import C: \\\\ 1. SQL // import // MySQL with source
==================================< br> Import
command :. import
SQLite>. import file name table name
Note 1: Do not forget the start point
NOTE 2: This statement cannot end with a semicolon. non-SQL statements do not need to end with a semicolon.
Note 3: Check the default separator. must be consistent. otherwise, SQLite fields may be incorrectly divided.
View the delimiter command. show, which can be modified directly if they are inconsistent, for example:
SQLite>. separator ","
convert the separator into a comma.
Example 1:
import the data in file a.txt to table tab_xx. (fields in a.csv are separated by commas)
SQLite>. separator ","
SQLite>. import a.txt tab_xx
SQLite>
Import is complete.

Export
Implementation Method: redirects the output to a file.
Command:. Output
SQLite>. Output a.txt
Enter an SQL statement to query the data to be exported. 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.

If you need to import the file into a csvformat, you can directly convert the file a.txt to a.csv.

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.