Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11
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 // Note that in some but not all dialects, the data type of the column needs to be known to jOOQ and the RDBMS create.alterTable("table").alter(field("column", VARCHAR(10))).dropNotNull().execute();
Dialect support
This example using jOOQ:
alterTable("t").alter(field("c", VARCHAR(10))).dropNotNull()
Translates to the following dialect specific expressions:
ASE, Oracle
ALTER TABLE t MODIFY c NULL
Aurora MySQL, MariaDB, MySQL
ALTER TABLE t CHANGE COLUMN c c varchar(10) NULL
Aurora Postgres, CockroachDB, DB2, Derby, DuckDB, Firebird, H2, HSQLDB, Postgres, Snowflake, YugabyteDB
ALTER TABLE t ALTER c DROP NOT NULL
Databricks, Vertica
ALTER TABLE t ALTER COLUMN c DROP NOT NULL
Exasol
ALTER TABLE t MODIFY c DROP NOT NULL
MemSQL
ALTER TABLE t MODIFY c varchar(10) NULL
Access, BigQuery, ClickHouse, Hana, Informix, Redshift, SQLDataWarehouse, SQLServer, SQLite, Sybase, Teradata, Trino
/* UNSUPPORTED */
Generated with jOOQ 3.21. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!