You can use cascade truncate operations to a reference partitioned child table with the CASCADE
option of TRUNCATE
TABLE
, ALTER
TABLE
TRUNCATE
PARTITION
, and ALTER
TABLE
TRUNCATE
SUBPARTITION
SQL statements.
When the CASCADE
option is specified for TRUNCATE
TABLE
, the truncate table operation also truncates child tables that reference the targeted table through an enabled referential constraint that has ON
DELETE
CASCADE
enabled. This cascading action applies recursively to grandchildren, great-grandchildren, and so on. After determining the set of tables to be truncated based on the enabled ON
DELETE
CASCADE
referential constraints, an error is raised if any table in this set is referenced through an enabled constraint from a child outside of the set. If a parent and child are connected by multiple referential constraints, a TRUNCATE
TABLE
CASCADE
operation targeting the parent succeeds if at least one constraint has ON
DELETE
CASCADE
enabled.
Privileges are required on all tables affected by the operation. Any other options specified for the operation, such as DROP
STORAGE
or PURGE
MATERIALIZED
VIEW
LOG
, apply for all tables affected by the operation.
truncate_table ::= TRUNCATE TABLE [schema.] table [ {PRESERVE | PURGE} MATERIALIZED VIEW LOG ] [ {DROP [ ALL ] | REUSE} STORAGE ] [ CASCADE ]
When the CASCADE
option is specified, the TRUNCATE
PARTITION
and TRUNCATE
SUBPARTITION
operations cascade to reference partitioned tables that are children of the targeted table. The TRUNCATE
can be targeted at any level in a reference partitioned hierarchy and cascades to child tables starting from the targeted table. Privileges are not required on the child tables, but the usual restrictions on the TRUNCATE
operation, such as the table cannot be referenced by an enabled referential constraint that is not a partitioning constraint, apply for all tables affected by the operation.
The CASCADE
option is ignored if it is specified for a table that does not have reference partitioned children. Any other options specified for the operation, such as DROP
STORAGE
or UPDATE
INDEXES
, apply to all tables affected by the operation.
The cascade options are off by default so they do not affect Oracle Database compatibility.
truncate_partition_subpart ::= TRUNCATE { partition_extended_name | subpartition_extended_name } [ { DROP [ ALL ] | REUSE } STORAGE ] [ update_index_clauses [ parallel_clause ]] [ CASCADE ]