SQLite - DROP Table

Advertisements


The SQLite DROP TABLE statement is used to remove a table definition and all associated data, indexes, triggers, constraints and permission specifications for that table.

You have to be careful while using this command because once a table is deleted then all the information available in the table would also be lost forever.

Syntax:

Basic syntax of DROP TABLE statement is as follows. You can optionally specify database name along with table name as follows:

DROP TABLE database_name.table_name;

Example:

Let us first verify COMPANY table and then we would delete it from the database.

sqlite>.tables
COMPANY       test.COMPANY

This means COMPANY table is available in the database, so let us drop it as follows:

sqlite>DROP TABLE COMPANY;
sqlite>

Now, if you would try .TABLES command then you will not find COMPANY table anymore:

sqlite>.tables
sqlite>

It shows nothing means the table from your database has been dropped successfully.



Advertisements
Advertisements