Available in versions: Dev (3.22)

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

SET CONSTRAINTS

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Constraint deferrability is a useful feature that allows for specifying the default deferrability mode on a constraint at data definition time. It is often useful to immediately enforce a constraint by default, but to defer enforcement for the scope of a single transaction that profits from disabling the constraint, e.g. to speed up certain data migration operations. This temporary session setting can be achieved with the SET CONSTRAINTS statement:

SET CONSTRAINTS constraint_name DEFERRED;
create.setConstraints("constraint_name").deferred().execute();

See also constraint enforcement in CREATE TABLE.

Dialect support

This example using jOOQ:

setConstraints("c").deferred()

Translates to the following dialect specific expressions:

Aurora Postgres, Oracle, Postgres, YugabyteDB

SET CONSTRAINTS c DEFERRED

ASE, Access, Aurora MySQL, BigQuery, ClickHouse, CockroachDB, DB2, Databricks, DuckDB, Exasol, Firebird, H2, HSQLDB, Hana, Informix, MariaDB, MemSQL, MySQL, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Spanner, Sybase, Teradata, Trino, Vertica

/* UNSUPPORTED */
Generated with jOOQ 3.22. 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!

The jOOQ Logo