Skip to content

Commit 706e556

Browse files
committed
Update comment and database-comment
1 parent 9533907 commit 706e556

File tree

2 files changed

+76
-33
lines changed

2 files changed

+76
-33
lines changed
Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
---
2-
description: 'Documentation for ALTER TABLE ... MODIFY COMMENT'
3-
sidebar_label: 'COMMENT'
2+
description: 'Documentation for ALTER TABLE ... MODIFY COMMENT which allow
3+
adding, modifying, or removing table comments'
4+
sidebar_label: 'ALTER TABLE ... MODIFY COMMENT'
45
sidebar_position: 51
56
slug: /sql-reference/statements/alter/comment
67
title: 'ALTER TABLE ... MODIFY COMMENT'
8+
keywords: ['ALTER TABLE', 'MODIFY COMMENT']
79
---
810

911
# ALTER TABLE ... MODIFY COMMENT
1012

11-
Adds, modifies, or removes comment to the table, regardless if it was set before or not. Comment change is reflected in both [system.tables](../../../operations/system-tables/tables.md) and `SHOW CREATE TABLE` query.
13+
Adds, modifies, or removes a table comment, regardless of whether it was set
14+
before or not. The comment change is reflected in both [`system.tables`](../../../operations/system-tables/tables.md)
15+
and in the `SHOW CREATE TABLE` query.
1216

13-
**Syntax**
17+
## Syntax {#syntax}
1418

1519
```sql
1620
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment'
1721
```
1822

19-
**Examples**
23+
## Examples {#examples}
2024

21-
Creating a table with comment (for more information, see the [COMMENT](/sql-reference/statements/create/table#comment-clause) clause):
25+
To create a table with a comment:
2226

2327
```sql
2428
CREATE TABLE table_with_comment
@@ -30,38 +34,56 @@ ENGINE = Memory()
3034
COMMENT 'The temporary table';
3135
```
3236

33-
Modifying the table comment:
37+
To modify the table comment:
3438

3539
```sql
36-
ALTER TABLE table_with_comment MODIFY COMMENT 'new comment on a table';
37-
SELECT comment FROM system.tables WHERE database = currentDatabase() AND name = 'table_with_comment';
40+
ALTER TABLE table_with_comment
41+
MODIFY COMMENT 'new comment on a table';
3842
```
3943

40-
Output of a new comment:
44+
To view the modified comment:
4145

42-
```text
46+
```sql title="Query"
47+
SELECT comment
48+
FROM system.tables
49+
WHERE database = currentDatabase() AND name = 'table_with_comment';
50+
```
51+
52+
```text title="Response"
4353
┌─comment────────────────┐
4454
│ new comment on a table │
4555
└────────────────────────┘
4656
```
4757

48-
Removing the table comment:
58+
To remove the table comment:
4959

5060
```sql
5161
ALTER TABLE table_with_comment MODIFY COMMENT '';
52-
SELECT comment FROM system.tables WHERE database = currentDatabase() AND name = 'table_with_comment';
5362
```
5463

55-
Output of a removed comment:
64+
To verify that the comment was removed:
65+
66+
```sql title="Query"
67+
SELECT comment
68+
FROM system.tables
69+
WHERE database = currentDatabase() AND name = 'table_with_comment';
70+
```
5671

57-
```text
72+
```text title="Response"
5873
┌─comment─┐
5974
│ │
6075
└─────────┘
6176
```
6277

63-
**Caveats**
78+
## Caveats {#caveats}
79+
80+
For Replicated tables, the comment can be different on different replicas.
81+
Modifying the comment applies to a single replica.
82+
83+
The feature is available since version 23.9. It does not work in previous
84+
ClickHouse versions.
6485

65-
For Replicated tables, the comment can be different on different replicas. Modifying the comment applies to a single replica.
86+
## Related content {#related-content}
6687

67-
The feature is available since version 23.9. It does not work in previous ClickHouse versions.
88+
- [`COMMENT`](/sql-reference/statements/create/table#comment-clause) clause
89+
- [`ALTER DATABASE ... MODIFY COMMENT`](./database-comment.md)
Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,76 @@
11
---
2-
description: 'Documentation for ALTER DATABASE ... MODIFY COMMENT Statements'
2+
description: 'Documentation for ALTER DATABASE ... MODIFY COMMENT statements
3+
which allow adding, modifying, or removing database comments.'
34
slug: /sql-reference/statements/alter/database-comment
45
sidebar_position: 51
5-
sidebar_label: 'UPDATE'
6+
sidebar_label: 'ALTER DATABASE ... MODIFY COMMENT'
67
title: 'ALTER DATABASE ... MODIFY COMMENT Statements'
8+
keywords: ['ALTER DATABASE', 'MODIFY COMMENT']
79
---
810

911
# ALTER DATABASE ... MODIFY COMMENT
1012

11-
Adds, modifies, or removes comment to the database, regardless of whether it was set before. Comment change is reflected in both [system.databases](/operations/system-tables/databases.md) and `SHOW CREATE DATABASE` query.
13+
Adds, modifies, or removes a database comment, regardless of whether it was set
14+
before or not. The comment change is reflected in both [`system.databases`](/operations/system-tables/databases.md)
15+
and the `SHOW CREATE DATABASE` query.
1216

13-
**Syntax**
17+
## Syntax {#syntax}
1418

1519
``` sql
1620
ALTER DATABASE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment'
1721
```
1822

19-
**Examples**
23+
## Examples {#examples}
2024

21-
Creating a DATABASE with comment (for more information, see the [COMMENT](/sql-reference/statements/create/table#comment-clause) clause):
25+
To create a `DATABASE` with a comment:
2226

2327
``` sql
2428
CREATE DATABASE database_with_comment ENGINE = Memory COMMENT 'The temporary database';
2529
```
2630

27-
Modifying the table comment:
31+
To modify the comment:
2832

2933
``` sql
30-
ALTER DATABASE database_with_comment MODIFY COMMENT 'new comment on a database';
31-
SELECT comment FROM system.databases WHERE name = 'database_with_comment';
34+
ALTER DATABASE database_with_comment
35+
MODIFY COMMENT 'new comment on a database';
3236
```
3337

34-
Output of a new comment:
38+
To view the modified comment:
39+
40+
```sql
41+
SELECT comment
42+
FROM system.databases
43+
WHERE name = 'database_with_comment';
44+
```
3545

3646
```text
3747
┌─comment─────────────────┐
3848
│ new comment on database │
3949
└─────────────────────────┘
4050
```
4151

42-
Removing the database comment:
52+
To remove the database comment:
4353

4454
``` sql
45-
ALTER DATABASE database_with_comment MODIFY COMMENT '';
46-
SELECT comment FROM system.databases WHERE name = 'database_with_comment';
55+
ALTER DATABASE database_with_comment
56+
MODIFY COMMENT '';
4757
```
4858

49-
Output of a removed comment:
59+
To verify that the comment was removed:
5060

51-
```text
61+
```sql title="Query"
62+
SELECT comment
63+
FROM system.databases
64+
WHERE name = 'database_with_comment';
65+
```
66+
67+
```text title="Response"
5268
┌─comment─┐
5369
│ │
5470
└─────────┘
5571
```
72+
73+
## Related content {#related-content}
74+
75+
- [`COMMENT`](/sql-reference/statements/create/table#comment-clause) clause
76+
- [`ALTER TABLE ... MODIFY COMMENT`](./comment.md)

0 commit comments

Comments
 (0)