Renaming a Partition

Function

This statement is used to rename partitions.

Syntax

1
2
3
ALTER TABLE table_name
  PARTITION partition_specs
  RENAME TO PARTITION partition_specs;

Keyword

None

Precautions

  • The table and partition to be renamed must exist. Otherwise, an error occurs. The name of the new partition must be unique. Otherwise, an error occurs.
  • If a table is partitioned using multiple fields, you are required to specify all the fields of a partition (at random order) when renaming the partition.
  • By default, the partition_specs parameter contains (). For example: PARTITION (dt='2009-09-09',city='Shanghai')

Example

To modify the name of the city='Hangzhou',dt='2008-08-08' partition in the student table to city='Wenzhou',dt='2009-09-09', run the following statement:

1
2
3
ALTER TABLE student
  PARTITION (city='Hangzhou',dt='2008-08-08')
  RENAME TO PARTITION (city='Wenzhou',dt='2009-09-09');