Truncate a partition
Updated at:
Use the TRUNCATE statement to remove all rows from a partition without scanning the table. TRUNCATE is faster than DELETE and immediately reclaims disk space, eliminating the need for a subsequent VACUUM.
Syntax
TRUNCATE [ PARTITION ] name [ CASCADE | RESTRICT ]Parameters
| Parameter | Description |
|---|---|
PARTITION | Optional keyword. Including it does not change the behavior of the statement. |
name | The name of the partition to truncate. |
CASCADE | Automatically truncate all tables that have foreign-key references to the named partition. |
RESTRICT | Refuse to truncate if any other table has a foreign-key reference to the named partition. |
Examples
Truncate a partition named tab_range:
TRUNCATE tab_range;Truncate a partition and cascade to all tables with foreign-key references:
TRUNCATE tab_range CASCADE;Is this page helpful?