Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
CASCADE
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
When dropping a table, the CASCADE
clause extends the dropping to all dependent objects, including views, etc. The following two syntactic elements can be added to a DROP TABLE
statement:
-
RESTRICT
(the default): TheDROP
operation should fail if there are any dependent objects, such as views. -
CASCADE
: TheDROP
operation should succeed if there are any dependent objects, and drop those as well.
This is a potentially very dangerous operation. While dropping dependent views seems reasonable, some RDMS may also drop dependent child tables if theirFOREIGN KEY
constraints point to the dropped table. Use theCASCADE
clause with great care!
Dialect support
This example using jOOQ:
dropTable("t").cascade()
Translates to the following dialect specific expressions:
CockroachDB, DuckDB, Exasol, H2, HSQLDB, Hana, Informix, Postgres, Redshift, Snowflake, Vertica, YugabyteDB
DROP TABLE t CASCADE
Oracle
DROP TABLE t CASCADE CONSTRAINTS
ASE, Access, Aurora MySQL, Aurora Postgres, BigQuery, ClickHouse, DB2, Databricks, Derby, Firebird, MariaDB, MemSQL, MySQL, SQLDataWarehouse, SQLServer, SQLite, Sybase, Teradata, Trino
/* UNSUPPORTED */
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!