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 .. DROP NOT NULL

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

An existing column's NOT NULL constraint can be dropped using the ALTER TABLE's NOT NULL clause on a column:

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

Dialect support

This example using jOOQ:

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

Translates to the following dialect specific expressions:

ASE, Oracle

ALTER TABLE t MODIFY c NULL

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

ALTER TABLE t ALTER c DROP NOT NULL

Exasol

ALTER TABLE t MODIFY c DROP NOT NULL

Vertica

ALTER TABLE t ALTER COLUMN c DROP 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