Analytics

Sunday, March 24, 2013

Oracle TRUNCATE TABLE

A statement like delete from tablename deletes all records in the table, but it does not free any space (see On table sizes).
In order to free the space as well, use truncate. However, a truncate can not be rolled back.

Basically, a truncate statement resets the high water mark to its initial position.

A truncate statement cannot be used on a synonym.

TRUNCATE TABLE Demo

SQL> TRUNCATE TABLE purchase;

Table truncated.

SQL>
SQL> SELECT * FROM purchase;

no rows selected

No comments:

Post a Comment