Skip to main content
Skip to main content

ALTER-TABLE-RENAME

ALTER-TABLE-RENAME

Name

ALTER TABLE RENAME

Description

This statement is used to rename certain names of existing table properties. This operation is synchronous, and the return of the command indicates the completion of the execution.

grammar:

ALTER TABLE [database.]table alter_clause;

The alter_clause of rename supports modification of the following names

  1. Modify the table name

grammar:

RENAME new_table_name;
  1. Modify the rollup index name

    grammar:

RENAME ROLLUP old_rollup_name new_rollup_name;
  1. Modify the partition name

grammar:

RENAME PARTITION old_partition_name new_partition_name;
  1. Modify the column name
Tips

This feature is supported since the Apache Doris 1.2 version

Modify the column name

grammar:

RENAME COLUMN old_column_name new_column_name;

Notice:

  • When creating a table, you need to set 'light_schema_change=true' in the property.

Example

  1. Modify the table named table1 to table2
ALTER TABLE table1 RENAME table2;
  1. Modify the rollup index named rollup1 in the table example_table to rollup2
ALTER TABLE example_table RENAME ROLLUP rollup1 rollup2;
  1. Modify the partition named p1 in the table example_table to p2
ALTER TABLE example_table RENAME PARTITION p1 p2;
  1. Modify the column named c1 in the table example_table to c2
ALTER TABLE example_table RENAME COLUMN c1 c2;

Keywords

ALTER, TABLE, RENAME, ALTER TABLE

Best Practice