Truncate

From Oracle FAQ
(Redirected from TRUNCATE)
Jump to: navigation, search

Truncate is a SQL DDL command that removes all data from a table. One cannot ROLLBACK after executing a TRUNCATE statement and the data within it will be permanently lost.

Examples[edit]

Remove all data and storage allocated to a table:

TRUNCATE table emp;

Retain the allocated space from deleted rows (don't reset the row high water mark) - this is quicker, but will not release any space:

TRUNCATE TABLE emp REUSE STORAGE;

Preserve the data in MVIEW logs (needed for fast refresh):

TRUNCATE TABLE emp PRESERVE MATERIALIZED VIEW LOG; 

Verify if table storage was retained after a TRUNCATE operation:

SELECT SUM(blocks) FROM user_segments WHERE segment_name = 'EMP';

Also see[edit]

Glossary of Terms
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z #