> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> テーブルコメントの追加、変更、削除を行う ALTER TABLE ... MODIFY COMMENT のドキュメント

# ALTER TABLE ... MODIFY COMMENT

事前に設定されているかどうかに関係なく、テーブルコメントを追加、変更、または削除します。コメントの変更は、[`system.tables`](/ja/reference/system-tables/tables) と `SHOW CREATE TABLE` クエリの両方に反映されます。

<div id="syntax">
  ## 構文
</div>

```sql theme={null}
ALTER TABLE [db].name [ON CLUSTER cluster] MODIFY COMMENT 'Comment'
```

<div id="examples">
  ## 例
</div>

コメント付きのテーブルを作成するには:

```sql title="Query" theme={null}
CREATE TABLE table_with_comment
(
    `k` UInt64,
    `s` String
)
ENGINE = Memory()
COMMENT 'The temporary table';
```

テーブルコメントを変更するには:

```sql title="Query" theme={null}
ALTER TABLE table_with_comment 
MODIFY COMMENT 'new comment on a table';
```

変更後のコメントを表示するには:

```sql title="Query" theme={null}
SELECT comment 
FROM system.tables 
WHERE database = currentDatabase() AND name = 'table_with_comment';
```

```text title="Response" theme={null}
┌─comment────────────────┐
│ new comment on a table │
└────────────────────────┘
```

テーブルコメントを削除するには:

```sql title="Query" theme={null}
ALTER TABLE table_with_comment MODIFY COMMENT '';
```

コメントが削除されていることを確認するには:

```sql title="Query" theme={null}
SELECT comment 
FROM system.tables 
WHERE database = currentDatabase() AND name = 'table_with_comment';
```

```text title="Response" theme={null}
┌─comment─┐
│         │
└─────────┘
```

<div id="caveats">
  ## 注意事項
</div>

レプリケートテーブルでは、コメントがレプリカごとに異なる場合があります。
コメントの変更は、1 つのレプリカにのみ適用されます。

この機能はバージョン 23.9 以降で利用できます。以前の
ClickHouse バージョンでは動作しません。

<div id="related-content">
  ## 関連コンテンツ
</div>

* [`COMMENT`](/ja/reference/statements/create/table#comment-clause) 句
* [`ALTER DATABASE ... MODIFY COMMENT`](/ja/reference/statements/alter/database-comment)
