Truncate Table
Truncate Table
Purpose
Note:
You cannot roll back a TRUNCATE TABLE statement, nor can you use a
FLASHBACK
TABLE statement to retrieve the contents of a table that has been truncated.
Use the TRUNCATE TABLE statement to remove all rows from a table. By default,
Oracle
Database also performs the following tasks:
• Deallocates all space used by the removed rows except that specified by the
MINEXTENTS
storage parameter
• Sets the NEXT storage parameter to the size of the last extent removed from
the segment
by the truncation process
Removing rows with the TRUNCATE TABLE statement can be more efficient than
dropping and recreating
a table. Dropping and re-creating a table invalidates dependent objects of the
table,
and requires you to repeat the following actions:
• Grant object privileges on the table
• Create the indexes, integrity constraints, and triggers on the table
• Specify the storage parameters of the table
Truncating has none of these effects.
Removing rows with the TRUNCATE TABLE statement can be faster than
removing all rows with
the DELETE statement, especially if the table has numerous triggers, indexes,
and other
dependencies.
See Also:
• DELETE and DROP TABLE for information on other ways of removing data from
a table
• TRUNCATE CLUSTER for information on truncating a cluster
Prerequisites
To truncate a table, the table must be in your schema or you must have the
DROP ANY TABLE
system privilege.
To specify the CASCADE clause, all affected child tables must be in your schema
or you must
have the DROP ANY TABLE system privilege.
You can truncate a private temporary table with the existing TRUNCATE TABLE
command.
Truncating a private temporary table will not commit and existing transaction.
This applies to
both transaction-specific and session-specific private temporary tables. Note that
a truncated
private temporary table will not go into the RECYCLEBIN.
Chapter 19
TRUNCATE TABLE
19