Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

ALTER TABLE .. DROP CONSTRAINT

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

A constraint can be dropped from the table using the ALTER TABLE's DROP CONSTRAINT clause:

// Drop a constraint
create.alterTable("table").dropConstraint("uk").execute();

Alternative syntaxes are available to restrict dropping only to specific types of constraints:

  • DROP PRIMARY KEY
  • DROP UNIQUE
  • DROP FOREIGN KEY

Dialect support

This example using jOOQ:

alterTable("t").dropConstraint("c")

Translates to the following dialect specific expressions:

ASE, Access, Aurora Postgres, CockroachDB, DB2, Derby, Exasol, Firebird, H2, HSQLDB, Hana, Informix, MariaDB, Oracle, Postgres, Redshift, SQLDataWarehouse, SQLServer, Snowflake, Sybase, Teradata, Vertica, YugabyteDB

ALTER TABLE t DROP CONSTRAINT c

BigQuery, ClickHouse

ALTER TABLE t DROP PRIMARY KEY

Aurora MySQL, DuckDB, MemSQL, MySQL, SQLite, Trino

/* UNSUPPORTED */
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo