Tables, Dropping

When you no longer need a table, you can drop it from your schema:

DROP TABLE table_name;

In Oracle, you can drop a table that is referenced by foreign key constraints using the following syntax:

DROP TABLE table_name CASCADE CONSTRAINTS;

In PostgreSQL, you can do the same thing using:

DROP TABLE table_name CASCADE;

Foreign key constraints that reference the table being dropped will be dropped themselves.

Note

In DB2, referencing foreign key constraints are always dropped; no CASCADE clause is needed.

In all other cases, you must drop any referencing foreign key constraints manually before dropping the referenced table.

Get SQL Pocket Guide, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.