Thursday, 11 October 2012

Lesson : 17 : TRUNCATE Statement


Syntax :

 TRUNCATE TABLE <tablename>  DROP / RESUSE  STORAGE;
 

·         Removes all rows/records of given table

·         Is a DDL command, so Commit is NOT required

·         Can’t rollback after remove rows by truncate

·         Deallocates all space used by the removed rows

·         Faster than delete command

·         DROP STORAGE option is to deallocate all space from the deleted rows from the table

·         REUSE STORAGE option is to retain the space from the deleted rows allocated to the table
 

Examples :

1)      SQL> TRUNCATE TABLE emp;


-          Removes all records from emp table


2)      SQL> TRUNCATE TABLE emp REUSE STORAGE;

               -          Removes all records from emp table and it retains the space from the deleted rows allocated to the emp table.

 

No comments:

Post a Comment