ALTER TABLE ... MODIFY COMMENT
添加、修改或删除表注释,无论之前是否设置过。注释的更改反映在 system.tables
和 SHOW CREATE TABLE
查询中。
Syntax
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment'
Examples
要创建带有注释的表:
CREATE TABLE table_with_comment
(
`k` UInt64,
`s` String
)
ENGINE = Memory()
COMMENT 'The temporary table';
要修改表注释:
ALTER TABLE table_with_comment
MODIFY COMMENT 'new comment on a table';
要查看修改后的注释:
SELECT comment
FROM system.tables
WHERE database = currentDatabase() AND name = 'table_with_comment';
┌─comment────────────────┐
│ new comment on a table │
└────────────────────────┘
要删除表注释:
ALTER TABLE table_with_comment MODIFY COMMENT '';
要验证注释是否已被删除:
SELECT comment
FROM system.tables
WHERE database = currentDatabase() AND name = 'table_with_comment';
┌─comment─┐
│ │
└─────────┘
Caveats
对于副本表,不同副本上的注释可能不同。修改注释仅适用于单一副本。
该功能自 23.9 版本起可用。在之前的 ClickHouse 版本中无法使用。
Related content