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 .. ALTER COLUMN .. SET NOT NULL

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

A column can be set to NOT NULL using the ALTER TABLE's NOT NULL clause on a column:

// Specify the not null constraint on a column
create.alterTable("table").alter("column").setNotNull().execute();

The existing data in the column must not contain any nulls or an error will be raised.

Dialect support

This example using jOOQ:

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

Translates to the following dialect specific expressions:

ASE, Oracle

ALTER TABLE t MODIFY c NOT NULL

Aurora Postgres, CockroachDB, DB2, Derby, DuckDB, Firebird, H2, HSQLDB, Postgres, Snowflake, YugabyteDB

ALTER TABLE t ALTER c SET NOT NULL

Exasol

ALTER TABLE t MODIFY c SET NOT NULL

Vertica

ALTER TABLE t ALTER COLUMN c SET NOT NULL

Access, Aurora MySQL, BigQuery, ClickHouse, Hana, Informix, MariaDB, MemSQL, MySQL, Redshift, SQLDataWarehouse, SQLServer, SQLite, Sybase, Teradata, 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