Updated on 2025-04-21 GMT+08:00

RENAME COLUMN

Function

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

Precautions

  • If your table is already on the desired protocol version, you need to execute the following statement before the modification can be successful:
    ALTER TABLE table_name SET TBLPROPERTIES ('delta.columnMapping.mode' = 'name');
  • If your table is not on the desired protocol version, you need to execute the following statement before the modification can be successful:
    ALTER TABLE table_name SET TBLPROPERTIES (
    'delta.columnMapping.mode' = 'name',
    'delta.minReaderVersion' = '2',
    'delta.minWriterVersion' = '5')

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.

Required Permissions

  • SQL permissions
Table 2 Permissions required for executing ALTER TABLE

Permission Description

ALTER permission on a table

  • Fine-grained permission: dli:table:alter
  • Metadata services provided by LakeFormation. Refer to the LakeFormation documentation for details on permission configuration.

Example

ALTER TABLE table1 RENAME COLUMN addr to address

ALTER TABLE table1 RENAME COLUMN addr.priv to province

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

Response

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