Back to Clickhouse

ALTER DATABASE ... MODIFY COMMENT Statements

docs/en/sql-reference/statements/alter/database-comment.md

26.4.1.1-new1.5 KB
Original Source

ALTER DATABASE ... MODIFY COMMENT

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

Syntax {#syntax}

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

Examples {#examples}

To create a DATABASE with a comment:

sql
CREATE DATABASE database_with_comment ENGINE = Memory COMMENT 'The temporary database';

To modify the comment:

sql
ALTER DATABASE database_with_comment 
MODIFY COMMENT 'new comment on a database';

To view the modified comment:

sql
SELECT comment 
FROM system.databases 
WHERE name = 'database_with_comment';
text
┌─comment─────────────────┐
│ new comment on database │
└─────────────────────────┘

To remove the database comment:

sql
ALTER DATABASE database_with_comment 
MODIFY COMMENT '';

To verify that the comment was removed:

sql
SELECT comment 
FROM system.databases 
WHERE  name = 'database_with_comment';
text
┌─comment─┐
│         │
└─────────┘