Remove a table and all its data.

Permanently removes a table and all its data, triggering any associated triggers and constraints. Irreversible. Use CASCADE with caution -- it drops dependent objects too. Prefer soft deletes (is_deleted flag) if you need auditability.

Compatibility

Show:
Database System Support Status Since Version Notes
MySQL ✓ Supported all CASCADE available
PostgreSQL ✓ Supported all CASCADE / RESTRICT
SQL Server ✓ Supported all IF EXISTS in 2016+
Oracle ✓ Supported all PURGE option
SQLite ✓ Supported all IF EXISTS

Details

DDL to remove a table.

Standard Syntax

DROP TABLE table_name;

Version Support

MySQL: Since all PostgreSQL: Since all SQL Server: Since all Oracle: Since all SQLite: Since all

Per-Database Syntax & Notes

MySQL

CASCADE available

DROP TABLE IF EXISTS tbl;

PostgreSQL

CASCADE / RESTRICT

DROP TABLE IF EXISTS tbl CASCADE;

SQL Server

IF EXISTS in 2016+

DROP TABLE IF EXISTS tbl;

Oracle

PURGE option

DROP TABLE tbl PURGE;

SQLite

IF EXISTS

DROP TABLE IF EXISTS tbl;