General Note: Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

In this tutorial, you will learn how to export data in SQLite.

SQLite has two kind of export.

1. .output

2. .save

OUTPUT

By using SQLite, we can easily export table to csv file. To achieve this concept we using .output keyword follow the steps to export table to  csv format

step 1:  run the command .separator ","

step 2: .output filename.extension . For example .output table1.csv

step 3: execute any select query. The result will be stored in the table1.csv file . For example select * from company_location;

step 4: .output (returning the output screen to the command prompt)

SAVE

save keyword is used  write in-memory database into file.


sqlite> ... many SQL commands omitted ...
sqlite> .save ex1.db
sqlite>

Be careful when using the ".save" command as it will overwrite any preexisting database files having the same name without prompting for confirmation.

As with the ".open" command, you might want to use a full pathname with forward-slash directory separators to avoid ambiguity.