The TRUNCATE statement in Oracle SQL is used to quickly remove all rows from a table while retaining its structure for future use.
Syntax:
TRUNCATE TABLE table_name;
Key Features of TRUNCATE:
✅ Fast and Efficient: TRUNCATE is faster than DELETE because it bypasses the transaction log for individual row deletions.
✅ Resets Storage: It releases the table’s storage back to the database (except the initial allocation).
✅ No WHERE Clause: Unlike DELETE, TRUNCATE removes all rows — no filtering allowed.
✅ Auto Commit: TRUNCATE is a DDL (Data Definition Language) command, so it commits automatically and cannot be rolled back.
✅ Does Not Fire Triggers: Since it’s a DDL operation, triggers are not activated.
✅ Cannot be Used with Foreign Key References: If the table is referenced by a foreign key, you cannot truncate it unless the constraint is dropped.
TRUNCATE TABLE employees;
When to Use TRUNCATE
When you need to remove all data from a table quickly.
When you don’t need to trigger associated actions like logging or cascading effects.