What is difference between delete and truncate
TRUNCATE
1. It is DDL command
2. Speed is faster
Reason: When you type DELETE, all the data is first copied into the Rollback Tablespace. Then the delete operation is performed. That's why, when you type ROLLBACK after deleting a table, you can get back the data. (The system gets it from the Rollback Tablespace.). All that processing takes time. But when you type TRUNCATE it removes the data directly without copying it into the Rollback Tablespace. That's why TRUNCATE is faster. Once you truncate you can't get back the data.
3. Do not Check Constraints.
4. Roll back is not possible.
5. Cannot use with where clause.
6. When a table is truncated the memory occupied is released.7. The truncate statement will result in clearing table spaces or memories and the table structure remain in the database. Therefore it frees table storage spaces; use it only when you need to remove all data from a table.8. Removes the data by deallocating the data pages used to store the table's data and only the page deallocations are recorded in the transaction log.

SubashPosted Sep 16, 2016, 12:38 AM
Nice share