This guide will describe the usage of the schema command in SQLite.
How to Use the Schema Command to Show Table Structure in SQLite?
To show table structure in SQLite by using the “.schema” command, check out the following instructions:
- Open the Windows terminal and switch to the SQLite folder.
- List all the databases and navigate to one of them.
- View the existing tables and choose the desired one.
- Run the “.schema <table-name>” command to show the table structure.
Step 1: Launch Windows Terminal
Search “Command Prompt” with the help of the “Startup” menu and open it:
Step 2: Navigate to SQLite Directory
Then, execute the “cd” command along with the “sqlite” folder name and navigate to it:
Step 3: Display Existing Databases
Now, display all the available SQLite databases by running the “.databases” command:
According to the given output, only one database exists named “mydatadb.db”:
Step 4: Navigate to Database
Execute the “.open” command along with the database name and navigate to it:
Step 5: View Database Table
Next, list the available database tables by using the “.table” command:
As you can see, the current working database contains two tables and we have selected the “employees_info” table for further process:
Step 6: Show Table Structure
Lastly, execute the “.schema” command along with the previously selected table name:
It can be seen that the structure of the “employees_info” table has been displayed which contains:
- “emID” column name that has “INT” data type.
- “empName”, “empDesigination”, and “empAddress” columns which have the “CHAR” data type:
You have learned the easiest way to show the table structure in SQLite using the “.schema” command.
Conclusion
To view the table structure in SQLite, the “.schema” command can be used. For that purpose, first, open the Windows terminal and switch to the SQLite folder. Then, list the databases and navigate to one of them. Next, view the existing tables, select the desired one, and execute the “.schema <table-name>” command. In this guide, we have illustrated the method of displaying the table structure in SQLite.