Skip to main content
Skip to main content
Edit this page

ALTER TABLE ... MODIFY COMMENT

Adds, modifies, or removes a table comment, regardless of whether it was set before or not. The comment change is reflected in both system.tables and in the SHOW CREATE TABLE query.

Syntax

ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment'

Examples

To create a table with a comment:

CREATE TABLE table_with_comment
(
    `k` UInt64,
    `s` String
)
ENGINE = Memory()
COMMENT 'The temporary table';

To modify the table comment:

ALTER TABLE table_with_comment 
MODIFY COMMENT 'new comment on a table';

To view the modified comment:

SELECT comment 
FROM system.tables 
WHERE database = currentDatabase() AND name = 'table_with_comment';
┌─comment────────────────┐
│ new comment on a table │
└────────────────────────┘

To remove the table comment:

ALTER TABLE table_with_comment MODIFY COMMENT '';

To verify that the comment was removed:

SELECT comment 
FROM system.tables 
WHERE database = currentDatabase() AND name = 'table_with_comment';
┌─comment─┐
│         │
└─────────┘

Caveats

For Replicated tables, the comment can be different on different replicas. Modifying the comment applies to a single replica.

The feature is available since version 23.9. It does not work in previous ClickHouse versions.