Available in versions: Dev (3.21)

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.

ALTER TABLE .. ALTER COLUMN .. SET GENERATED BY DEFAULT AS IDENTITY

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

A column IDENTITY flag can be added to a column using the ALTER TABLE's SET GENERATED BY DEFAULT AS IDENTITY clause on a column:

// Specify a new identity flag for a column
create.alterTable("table").alter("column").setGeneratedByDefaultAsIdentity().execute();

Dialect support

This example using jOOQ:

alterTable("t").alter("c").setGeneratedByDefaultAsIdentity()

Translates to the following dialect specific expressions:

Aurora Postgres, CockroachDB, Postgres, YugabyteDB

ALTER TABLE t ALTER c ADD GENERATED BY DEFAULT AS IDENTITY

DB2, HSQLDB

ALTER TABLE t ALTER c SET GENERATED BY DEFAULT AS IDENTITY

Exasol

ALTER TABLE t ALTER c SET IDENTITY

H2

ALTER TABLE t ALTER c SET GENERATED BY DEFAULT

ASE, Access, Aurora MySQL, BigQuery, ClickHouse, Databricks, Derby, DuckDB, Firebird, Hana, Informix, MariaDB, MemSQL, MySQL, Oracle, Redshift, SQLDataWarehouse, SQLServer, SQLite, Snowflake, Sybase, Teradata, Trino, Vertica

/* 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!

The jOOQ Logo