All Products
Search
Document Center

PolarDB:ALTER TABLE DROP SUBPARTITION

Last Updated:Jun 04, 2026

Permanently drops a subpartition and its data from a composite partitioned table. Back up the data before you run this statement.

Synopsis

ALTER TABLE table_name DROP SUBPARTITION subpartition_name;

Parameters

Parameter

Required

Description

Example

table_name

Yes

The composite partitioned table that contains the subpartition to drop.

customer_data

subpartition_name

Yes

The subpartition to drop.

p_2022_asia

Notes

  • You must be the table owner or a privileged user to run this command.

  • You cannot drop the last subpartition in a table.

  • DROP SUBPARTITION acquires a table-level exclusive lock AccessExclusiveLock. This lock blocks all DML and most DDL operations on the table. Run this statement during off-peak hours to avoid blocking other operations.

Examples

This example drops a subpartition from the customer_data composite partitioned table, which uses range partitioning by year and list subpartitioning by region.

Prepare the environment

Create a composite partitioned table named customer_data, range-partitioned by registration year and list-subpartitioned by region.

-- Create a composite partitioned table
CREATE TABLE customer_data (
    customer_id  INT NOT NULL,
    region       VARCHAR2(10),
    reg_date     DATE
)
PARTITION BY RANGE (reg_date)
SUBPARTITION BY LIST (region)
(
    PARTITION p_2022 VALUES LESS THAN (TO_DATE('2023-01-01', 'YYYY-MM-DD'))
    (
        SUBPARTITION p_2022_asia    VALUES ('Asia'),
        SUBPARTITION p_2022_europe  VALUES ('Europe')
    ),
    PARTITION p_2023 VALUES LESS THAN (TO_DATE('2024-01-01', 'YYYY-MM-DD'))
    (
        SUBPARTITION p_2023_asia    VALUES ('Asia'),
        SUBPARTITION p_2023_europe  VALUES ('Europe')
    )
);

-- Insert data
INSERT INTO customer_data VALUES (101, 'Asia', TO_DATE('2022-06-10', 'YYYY-MM-DD'));
INSERT INTO customer_data VALUES (102, 'Europe', TO_DATE('2022-07-20', 'YYYY-MM-DD'));
INSERT INTO customer_data VALUES (103, 'Asia', TO_DATE('2023-06-10', 'YYYY-MM-DD'));
INSERT INTO customer_data VALUES (104, 'Europe', TO_DATE('2023-07-20', 'YYYY-MM-DD'));

Perform the pre-check

Back up the subpartition data and verify the subpartition exists.

-- Important: Before you drop the subpartition, make sure that you have backed up the relevant data.

-- Check the subpartition structure to confirm that the p_2022_asia subpartition exists.
SELECT SUBPARTITION_NAME 
FROM USER_TAB_SUBPARTITIONS 
WHERE TABLE_NAME = 'CUSTOMER_DATA';

Run the command

Run DROP SUBPARTITION to drop p_2022_asia.

ALTER TABLE customer_data DROP SUBPARTITION p_2022_asia;

Verify the result

  1. Verify that the subpartition and its data have been dropped.

    -- Structure verification: Confirm that the subpartition is dropped.
    SELECT SUBPARTITION_NAME FROM USER_TAB_SUBPARTITIONS 
    WHERE TABLE_NAME = 'CUSTOMER_DATA';
    -- The query result no longer contains p_2022_asia.
    
    -- Data verification: Confirm that the data in the subpartition is dropped.
    SELECT COUNT(*) FROM customer_data WHERE customer_id = 101;
    -- The query result is 0.
  2. Update table statistics.

    Update statistics immediately after dropping a subpartition so the query optimizer generates accurate execution plans.

    ANALYZE CUSTOMER_DATA;

FAQ

Q1: Why do I get the ORA-00942: table or view does not exist error?

A: You lack ALTER privileges on the target table, or the table or schema name is misspelled. Verify your privileges and object names.

Q2: Why does the ORA-14006: invalid partition name error occur?
A: The subpartition name does not exist or is misspelled. Query ALL_TAB_SUBPARTITIONS to verify the name. Without double quotation marks, the database converts the name to uppercase for matching.



Q3: Why do I get the ORA-01031: insufficient privileges error?
A: You lack ALTER privileges on the target table. Contact your DBA to grant the required privileges.



Q4: Can data be recovered after running DROP SUBPARTITION?
A: No. DROP SUBPARTITION permanently deletes data and bypasses the Recycle Bin. Restore from a backup taken before the operation.



Related SQL statements