ALTER TABLE .. ALTER COLUMN .. DROP NOT NULL
适用于 ✅ 开源版 ✅ 专业版 ✅ 企业版
可以使用 ALTER TABLE
的 NOT NULL
子句来删除现有列的 NOT NULL
约束
// 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();
方言支持
此示例使用 jOOQ
alterTable("t").alter(field("c", VARCHAR(10))).dropNotNull()
翻译成以下特定方言的表达式
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 */
使用 jOOQ 3.21 生成。早期 jOOQ 版本的支持可能有所不同。 在我们的网站上翻译您自己的 SQL
反馈
您对此页面有任何反馈吗? 我们很乐意听到!