Updated on 2024-10-09 GMT+08:00

RENAME COLUMN

Function

The ALTER TABLE ... RENAME COLUMN command is used to change the column name.

Syntax

ALTER TABLE tableName RENAME COLUMN old_columnName TO new_columnName

Parameter Description

Table 1 RENAME COLUMN parameters

Parameter

Description

tableName

Table name.

old_columnName

Old column name.

new_columnName

New column name.

Example

ALTER TABLE table1 RENAME COLUMN a.b.c TO x

a.b.c indicates the full path of a nested column. For details about the nested column rules, see ADD COLUMNS.

After the column name is changed, the change is automatically synchronized to the column comment. The comment is in rename oldName to newName format.

Response

You can run the DESCRIBE command to view the new column name.