Removes all data from a specified partition while keeping the partition definition intact. This operation permanently deletes partition data. Back up any data you need before running this command, because data cannot be recovered after the operation.
Synopsis
ALTER TABLE table_name TRUNCATE PARTITION partition_name
[{DROP|REUSE} STORAGE]
Parameters
| Parameter | Required | Description | Example | |
|---|---|---|---|---|
table_name |
Yes | The name of the partitioned table. | sales_records |
|
partition_name |
Yes | The name of the partition to truncate. | p_2023_q1 |
|
| `{DROP | REUSE} STORAGE` | No | Parsed for Oracle syntax compatibility but has no effect on storage. | DROP STORAGE |
Usage notes
-
Run this command as the table owner or a user with the
ALTERprivilege on the table. -
TRUNCATE PARTITIONacquires a table-levelAccessExclusiveLock, which blocks all Data Manipulation Language (DML) 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. -
The operation is a metadata update combined with file deletion. It completes in seconds regardless of partition size—even for partitions with hundreds of millions of rows—with minimal I/O, CPU, and memory overhead.
-
If the table has
ON TRUNCATEtriggers, this operation fires them. Make sure you understand the business logic of those triggers before proceeding. -
The operation invalidates table statistics, which can degrade query performance. Run
ANALYZEon the parent table immediately after truncating a partition. -
TRUNCATE PARTITIONfails if the table has global indexes. A global index maintains uniqueness and access paths across all partitions, and the operation cannot clear the relevant index entries without compromising index integrity.
Example
This example clears a historical quarterly partition from a sales records table—a typical data lifecycle management task where you delete old data but keep the partition structure for future reuse.
Set up the environment
Check the partition before truncating
Truncate the partition
Verify and update statistics
FAQ
What is the difference between `TRUNCATE PARTITION` and `DROP PARTITION`?
TRUNCATE PARTITION deletes the data in a partition but keeps the partition definition. DROP PARTITION removes both the partition definition and its data. Use TRUNCATE PARTITION when you plan to reload data into the same partition later.
Can data be recovered after `TRUNCATE PARTITION`?
No. TRUNCATE PARTITION is a DDL operation that permanently deletes data. By default, it is not recorded in transaction logs and cannot be rolled back or recovered using standard flashback methods.
Why do I get the error `RA-02149: specified partition does not exist`?
The partition name does not exist or has a case mismatch. Verify the exact name with:
SELECT PARTITION_NAME FROM USER_TAB_PARTITIONS WHERE TABLE_NAME = 'SALES_RECORDS';
If the name contains lowercase letters or special characters, wrap it in double quotation marks.
Why do I get the error `ORA-01031: insufficient privileges`?
The current user does not have the ALTER privilege on the target table. Contact your database administrator to grant the required privilege.
Why do I get the error `ERROR: cannot truncate partition of table because it has global indexes`?
TRUNCATE PARTITION cannot remove data from a table that has global indexes, because a global index spans all partitions and the operation cannot safely clear only the affected index entries. Drop the global indexes before truncating the partition, or restructure the table to avoid global indexes.
Related SQL statements
-
ALTER TABLE DROP PARTITION: Removes a partition definition and all its data.
-
ALTER TABLE ADD PARTITION: Adds a new partition to a partitioned table.
-
ALTER TABLE SPLIT PARTITION: Splits one partition into two.