Dump Specific Table Using Dump Command

In this section we will see how we can use the dump command to dump a specific table of the database into a text file, not the entire database.

Sometimes, we might need to dump only a specific table into another file, not the entire database. For that, the syntax will change a bit. We need to provide the output filename as last time, but with the dump command, we need to provide the name of the specific table, which we want to dump.

Syntax:

.output <Location of File with Filename.Extension>
.dump <Table_Name>

Query:

Here, we will dump just the Employees table into a file named Employee_Table.txt

.output C:\Users\user\Downloads\SQLite\Employee_Table.txt
.dump Employees

Explanation: Here, just like the last time we are using the output dot-command and providing the entire path of the file in which we want to store the results / commands. But the difference is, here we just want to store the commands used to create and populate a certain table of the database, not the entire database. This is why we need to provide the name of the Table after the DUMP command to signify that we want to store the commands related to that table only.

Content of the Employee_Table Text File After Dumping:

Explanation: As we can see, only the details of the Employees table has been saved / dumped. Not the entire Database.

SQLite Dump Command

SQL stands for Structured Query Language, which is the common language (with minor changes) used to manipulate relational databases. It is used to create, store, retrieve, and manipulate databases and tables. SQLite is a lightweight version of SQL with some major changes, it doesn’t have a separate server, it is not a common language, and it can’t connect with databases like Oracle or MySQL server.

In this article, we will learn about DUMP Command in SQLite in depth along with its examples, practical implementations, and so on.

Similar Reads

SQLite DUMP

The DUMP command in SQLite is used to Backup or Restore any Database, Table, or Schema. But unlike other Functions of SQLite, the DUMP command is used with e “.” (Dot) in front of it. These types of SQLite commands are called Dot-Commands. DUMP commands are used to dump Tables, Databases, Schemas, etc to some other file....

How To Use The SQLite Dump Command

In this section, we will learn about the syntax and the working procedure of the DUMP dot command....

Dump Entire Database Into file using DUMP Command

Here, we will dump an entire database into a file using the DUMP command. To do that firstly, we need to provide the name and extension of the file in which we want to store the result with the .output command. Then we have to use the .dump command....

Dump Specific Table Using Dump Command

In this section we will see how we can use the dump command to dump a specific table of the database into a text file, not the entire database....

Dump Tables Structure Only Using Schema Command

Here we will see how we can only dump the schmea i.e the structure of the table or tables using the dump command. There is a variation of this command, using it alone will store the schema of all the tables present in database, but if we pass the name of a specific table then it will only store that....

Dump Data of One or More Tables Into File

Here we will see how we can dump the data of one or more tables into a file using the dump command, whenever we will use the SELECT statement, in the file we mentioned, all the INSERT commands we have used previously will be stored....

Conclusion

In this article, we saw how we can use the DUMP dot-command of SQLite3 for various purposes. Using it singularly or grouped together with other commands like Schema or Output, the main task what DUMP command does is to store the commands used to create the database, or any table, or the structure of any table....

Contact Us