Adds a new subpartition to a specified first-level partition of a composite partitioned table. Before running this statement, confirm that the parent partition has a subpartitioning policy defined and that the new subpartition's boundary or values do not conflict with existing subpartitions.
Synopsis
ALTER TABLE table_name
MODIFY PARTITION partition_name
ADD SUBPARTITION { list_subpartition | range_subpartition };
-- LIST subpartition definition
SUBPARTITION subpartition_name
VALUES (value[, value]...)
[TABLESPACE tablespace_name]
-- RANGE subpartition definition
SUBPARTITION subpartition_name
VALUES LESS THAN (value[, value]...)
[TABLESPACE tablespace_name]Parameters
| Parameter | Required | Description | Example |
|---|---|---|---|
table_name | Yes | The name of the target composite partitioned table. | sales_data |
partition_name | Yes | The name of the first-level partition to which the new subpartition is added. | p_2023 |
subpartition_name | Yes | The name of the new subpartition. Must be unique across all partitions and subpartitions in the table. | sp_q1_asia |
VALUES | Yes | The boundary values for the new subpartition. For a LIST subpartition, specify one or more literal values. For a RANGE subpartition, use VALUES LESS THAN to set the upper boundary. | VALUES ('Asia') or VALUES LESS THAN (TO_DATE(...)) |
TABLESPACE tablespace_name | No. Default: the table's default tablespace. | The tablespace for the new subpartition. | TABLESPACE users_tbs |
Usage notes
The subpartition type (LIST or RANGE) must match the type of existing subpartitions under the same parent partition.
subpartition_namemust be unique among all partitions and subpartitions in the table.When you add a RANGE subpartition, the boundary value defined by
VALUES LESS THAN (...)must be greater than the upper boundary of all existing subpartitions. RANGE subpartitions can only be appended in ascending order. To insert a subpartition in the middle, useALTER TABLE ... SPLIT SUBPARTITIONto split an existing subpartition.When you add a LIST subpartition, the values in its
VALUES (...)list cannot overlap with the values of any existing subpartitions in the same parent partition.Do not use
ADD SUBPARTITIONon a partition governed by aMAXVALUEorDEFAULTrule. Instead, useALTER TABLE ... SPLIT SUBPARTITIONto split the existing boundary partition.ADD SUBPARTITIONacquires a table-level exclusive lock (AccessExclusiveLock), which blocks all data manipulation language (DML) operations and most data definition language (DDL) operations on the table. Run this command during off-peak hours and allow enough time for it to complete.There is no stated limit on the number of subpartitions, but keep the total number of partitions per table under 1,000 for optimal performance and manageability.
If the table has an index, the database automatically creates a corresponding index partition for the new subpartition.
You must be the table owner or have administrator privileges to run this command.
The new subpartition initially has no statistics. To help the query optimizer generate accurate execution plans, gather statistics immediately after adding the subpartition.
Examples
Add a LIST subpartition to a RANGE-LIST composite partitioned table
This example adds a subpartition for the Africa region to the 2023 partition of a table that is composite-partitioned by sales year (RANGE) and sales region (LIST).
Add a RANGE subpartition to a RANGE-RANGE composite partitioned table
This example adds a subpartition for the second quarter (Q2) to the 2023 partition of a table that is composite-partitioned by order year (RANGE) and order date (RANGE).
FAQ
Why do I get `ORA-14321: subpartition ... already exists`?
The VALUES definition for the new subpartition conflicts with an existing one under the same parent partition. For a LIST subpartition, the value is already claimed by another subpartition. For a RANGE subpartition, the new boundary is not strictly higher than the last one. Specify a non-overlapping boundary value and retry.
Why do I get `ORA-02269: partition does not exist`?
The partition_name in the MODIFY PARTITION clause does not exist in the table. Query USER_TAB_PARTITIONS to get the correct name of the first-level partition.
Why do I get `ORA-14150: subpartitioning is not specified`?
The target table does not have a subpartitioning policy. ADD SUBPARTITION applies only to composite partitioned tables.
Why do I get `ORA-01031: insufficient privileges`?
The current user lacks the ALTER privilege on the target table. Contact a database administrator to grant the required privilege.
Why do I get `ORA-14074: partition bound must collate higher than that of the last partition`?
ADD SUBPARTITION can only append a RANGE subpartition at the end of the existing range in ascending order. To insert a subpartition in the middle, use ALTER TABLE ... SPLIT SUBPARTITION instead.
Related statements
ALTER TABLE ADD PARTITION: Adds a new first-level partition to a partitioned table.
ALTER TABLE DROP SUBPARTITION: Deletes a specified subpartition.
ALTER TABLE SPLIT SUBPARTITION: Splits one subpartition into two subpartitions.