SQLite | Table | Dropping a Table

This article explains how to drop an existing table.

Dropping an Existing Table

Use the DROP TABLE statement to drop an existing table. The syntax is as follows.

DROP TABLE table_name;

Dropping a table also removes the indexes and triggers associated with it.

For example, run the following statement to drop the mytable table.

drop table mytable;

Run the VACUUM statement to reclaim unused database space left after dropping a table. See Reclaiming Free Space (VACUUM) for information about VACUUM.

Now, let’s drop a table. First, use the SQLite .tables command to verify that the customer and user tables exist.

.tables
sqlite> .table
customer  user    
sqlite>

Drop the user table.

drop table user;
sqlite> drop table user;
sqlite>

Run .tables again to verify that the user table has been dropped.

sqlite> .table
customer    
sqlite> 

The result confirms that the user table has been dropped.