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

ALTER TABLE .. COMMENT

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

For convenience, jOOQ supports MySQL's COMMENT syntax also on ALTER TABLE, which corresponds to the more standard COMMENT ON TABLE statement

// Specify a new comment on a table
create.alterTable("table").comment("a comment describing the table").execute();

Dialect support

This example using jOOQ:

alterTable("t").comment("comment")

Translates to the following dialect specific expressions:

Aurora MySQL, MariaDB, MemSQL, MySQL

ALTER TABLE t COMMENT 'comment'

Aurora Postgres, CockroachDB, DB2, DuckDB, Exasol, Firebird, H2, HSQLDB, Hana, Oracle, Postgres, Teradata, Trino, Vertica, YugabyteDB

COMMENT ON TABLE t IS 'comment'

BigQuery

ALTER TABLE t SET OPTIONS (DESCRIPTION = 'comment')

ClickHouse

ALTER TABLE t MODIFY COMMENT 'comment'

Snowflake

ALTER TABLE t SET COMMENT = 'comment'

SQLServer

BEGIN TRY
  DECLARE @u varchar(max) = schema_name();
  EXEC sp_addextendedproperty 'MS_Description', 'comment', 'schema', @u, 'table', 't', DEFAULT, DEFAULT
END TRY
BEGIN CATCH
  EXEC sp_updateextendedproperty 'MS_Description', 'comment', 'schema', @u, 'table', 't', DEFAULT, DEFAULT
END CATCH

ASE, Access, Derby, Informix, Redshift, SQLDataWarehouse, SQLite, Sybase

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