Name

TRUNCATE TABLE

Synopsis

TRUNCATE TABLE [schema.]
table_name 
[{PRESERVE | PURGE} SNAPSHOT LOG
[{DROP | REUSE} STORAGE]

Removes all rows from a table (table_name).

Keywords

PRESERVE SNAPSHOT LOG

Keeps the contents of any snapshot log associated with the table. This allows you to reorganize the table without losing the snapshot log. This is the default.

PURGE SNAPSHOT LOG

Cleans out the snapshot log along with the table.

DROP STORAGE

Deallocates the storage used by the rows and returns the space to the free space pool. This is the default.

REUSE STORAGE

Retains the space used by the deleted rows. This is useful if the table or cluster will be reloaded with data.

Notes

The table to be truncated must be in your schema, or you must have the DROP ANY TABLE privilege to truncate a table in another schema. The TRUNCATE command does not create rollback records, so it cannot be rolled back. This characteristic makes TRUNCATE extremely fast, and it is preferable to DELETE FROM unless the rollback capability is required. When a table is truncated and the DROP STORAGE clause is specified, only the initial extent of the table is retained; all other storage is deallocated.

Example

The following example removes all the rows from scott’s emp table and deallocates the space used:

TRUNCATE TABLE scott.emp 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.164.195