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.
Now, we will not dump the contents of any table, but we will dump the structures of the table using the .schema command. .schema is a dot-command same as of the .dump command, it is used to dump only the structure or schema of the tables, just like the .dump command, it is used after the .output command.
Syntax:
.output <Location of File with Filename.Extension>
.schema
Query:
We will store the structure in a file called Table_Structure.txt. Write the below command to Dump the tables structure using the schema command:
.output C:\Users\user\Downloads\SQLite\Table_Structure.txt
.schema
Explanation: Just like everytime, we will first provide the entire path of the file in which we want to store the schema of the tables with the output dot command. Then we will call the schema dot command alone, and this will store every tables’ structure into that file.
Contents of the Table_Structure.txt:
Explanation: This stores the structures of all the tables present in the database.
If we want to store the structure of a specific Table of the database, then we need to provide the table name after the .schema command.
Syntax:
.output <Location of File with Filename.Extension>
.schema <Table_Name>
Query:
Saving the Schema of the Students table:
.output C:\Users\user\Downloads\SQLite\Student_Structure.txt
.schema Students
Explanation: Here after providing the path of the file in which we want to store the output, we are using the schema command alongside the table called Students. This is to signify that we want to store the schema of the only Students table, not every table present in database.
Contents of the Student_Structure.txt file:
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.