Home / SQL / Reference / Tables and design

SQL DROP TABLE

Delete a table and all its data.

Syntax

DROP TABLE [IF EXISTS] name;

There is no undo.

Example

Query (on the shop database used in the SQL course)

CREATE TABLE scratch (x INTEGER);
DROP TABLE IF EXISTS scratch;
SELECT COUNT(*) AS tables_called_scratch FROM sqlite_master WHERE name = 'scratch';

Result

tables_called_scratch
0

1 row

Related

Learn it step by step in the free lesson Creating Tables, with exercises that check your queries.