Renames a partition or subpartition. This is a metadata-only operation, but it can invalidate scripts that reference the legacy name. Before running this command, ensure the new name is unique and check for dependent code.
Synopsis
ALTER TABLE table_name RENAME PARTITION old_name TO new_name;
ALTER TABLE table_name RENAME SUBPARTITION old_name TO new_name;Parameters
Parameter | Required | Description | Example |
| Yes | The name of the target partitioned table. |
|
| Yes | The current name of the partition or subpartition to be renamed. |
|
| Yes | The new name for the partition or subpartition. |
|
Notes
You must be the table owner or have the
ALTERpermission on the table.RENAME PARTITIONacquires a table-level exclusive lockAccessExclusiveLockon the target partition. This lock blocks all Data Manipulation Language (DML) and most Data Definition Language (DDL) operations on the table. Run this statement during off-peak hours and allow sufficient time for it to complete to avoid blocking other critical operations on the table.The new partition or subpartition name must be unique within the table.
As a DDL operation, this command commits automatically and cannot be rolled back. To reverse the change, run another
RENAMEcommand to revert to the original name.If the legacy partition name is hardcoded in application code, stored procedures, or views, these objects will fail after the rename. Before renaming a partition, perform a thorough impact analysis and update all dependent code.
Examples
This example shows how to rename the subpartition sp_asia in the composite partitioned table customer_data to sp_2023_asia to align with the naming convention based on year and region.
Prepare the environment
Perform a pre-check
Run the command
Verify the result
FAQ
Q1: Why do I get the error ORA-14078: partition name is already in use?
This error indicates the specified new_name is already in use by another partition or subpartition in the same table. Choose a unique name.
Q2: Why do I get the error ORA-14076: partition name must be specified?
This error indicates that the specified old_name does not exist. Verify the name by following the pre-check steps.
Q3: After renaming a partition, why do my applications or scripts that reference it stop working?
This occurs when applications or scripts hardcode the old partition name. You must update all such references to use the new name.
Related SQL statements
ALTER TABLE ADD PARTITION: Adds a new partition to a partitioned table.
ALTER TABLE MERGE PARTITION: Merges two contiguous partitions into a single partition.
ALTER TABLE SPLIT PARTITION: Splits one partition into two partitions.
ALTER TABLE DROP PARTITION: Deletes a specified partition from a partitioned table.