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

ParameterDescription
PARTITIONOptional keyword. Including it does not change the behavior of the statement.
nameThe name of the partition to truncate.
CASCADEAutomatically truncate all tables that have foreign-key references to the named partition.
RESTRICTRefuse 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;