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
ALTER TABLE .. DROP FOREIGN KEY
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
A FOREIGN KEY
constraint can be dropped from the table using the ALTER TABLE
's DROP FOREIGN KEY
clause:
// Drop specific types of constraints create.alterTable("table").dropForeignKey("fk").execute();
Dialect support
This example using jOOQ:
alterTable("t").dropForeignKey("c")
Translates to the following dialect specific expressions:
ASE, Access, Aurora Postgres, CockroachDB, DB2, Databricks, Derby, Exasol, Firebird, H2, HSQLDB, Hana, Informix, Oracle, Postgres, Redshift, SQLDataWarehouse, SQLServer, Snowflake, Sybase, Teradata, Vertica, YugabyteDB
ALTER TABLE t DROP CONSTRAINT c
Aurora MySQL, MariaDB, MySQL
ALTER TABLE t DROP FOREIGN KEY c
BigQuery
ALTER TABLE t DROP PRIMARY KEY
ClickHouse, DuckDB, MemSQL, SQLite, 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!