TRUNCATE removes all rows(With DATA) from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
- TRUNCATE is a DDL command.
- You CAN NOT rollback in TRUNCATE.
- Truncate removes the record permanently.
- Truncate is DDL meaning all the data will be lost and only structure remains and we CAN NOT rollback. You CAN NOT use conditions(WHERE clause) in TRUNCATE.
- You cannot grant truncate, you must grant DROP ANY TABLE to SOMEONE, in order to let him truncate your table.
- TRUNCATE is much faster than DELETE.
Reason: When you type DELETE. All the data get copied into the Rollback Table space first then delete operation get performed.Thatswhy when you type ROLLBACK after deleting a table ,you can get back the data(The system get it for you from the ROLLBACK Table space).All this process take time. But when you type TRUNCATE, It removes data directly without copying it into the Rollback table space. That’s why TRUNCATE is faster. Once you truncate you CAN NOT get back the data.
Syntax:
SQL>TRUNCATE TABLE table_name;
Example: