Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

How do I dump the data, and only the data, not the schema, of some SQLite3 tables of a database (not all the tables)? The dump should be in SQL format, as it should be easily re-entered into the database later and should be done from the command line. Something like

sqlite3 db .dump

but without dumping the schema and selecting which tables to dump.

1 Answer

0 votes
by (40.7k points)

To get a CSV file, try using below code:

.mode csv 

-- use '.separator SOME_STRING' for something other than a comma.

.headers on 

.out file.csv 

select * from MyTable;

But, if you want to reinsert into a different SQLite database then use below code:

.mode insert <target_table_name>

.out file.sql 

select * from MyTable;

Related questions

0 votes
1 answer
0 votes
1 answer
asked Oct 5, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...