Updated on 2023-12-21 GMT+08:00

Modifying Column Comments

Function

You can modify the column comments of non-partitioned or partitioned tables.

Syntax

ALTER TABLE [db_name.]table_name CHANGE COLUMN col_name col_name col_type COMMENT 'col_comment';

Keyword

  • CHANGE COLUMN: Modify a column.
  • COMMENT: column description

Parameters

Table 1 Parameter description

Parameter

Mandatory

Description

db_name

No

Database name. Only letters, digits, and underscores (_) are allowed. The name cannot contain only digits or start with an underscore (_).

table_name

Yes

Table name

col_name

Yes

Column name. The value must be the name of an existing column.

col_type

Yes

Column data type specified when the table is created, which cannot be modified.

col_comment

Yes

Column comment after modification. The comment can contain a maximum of 1024 bytes.

Example

Change the comment of the c1 column in the t1 table to the new comment.

1
ALTER TABLE t1 CHANGE COLUMN c1 c1 STRING COMMENT 'the new comment';