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.

Code
6. When a table is truncated the memory occupied is released.
SQL
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.
VB.NET
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.
SQL
9. Removes all rows from a table but the table structure and its columns constraints indexes and so on remain. The counter used by an identity for new rows is reset to the seed for the column.
Code
10. You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint;
Code
11. Because TRUNCATE TABLE is not logged it cannot activate a trigger
Code
Code
Code
Code
DELETE
Code
Code
1. It is a DML command
Code
2. Speed is slow
Code
3. Check constraints, if exists then show error.
Code
4. We can rollback.
Code
5. User Where Clause
Code
6. is slower than truncate as it is dml has to go through rollback segments
VB.NET
7. We can use where clause with delete. When a table is deleted memory occupied is not released and also the water mark is not adjusted.
Code
8. The delete statement will result in the table spaces or memories would remain as the current size and table structure remain in the database.
Code
9. It is slower than the truncate command.
Code
10. Delete, use check constraints if exits then show error.
Code
11. Removes rows one at a time and records an entry in the transaction log for each deleted row.
CSS
12. If you want to retain the identity counter use DELETE instead. If you want to remove table definition and its data use the DROP TABLE statement.
Code
13. Activates Trigger
Code
Code
 http://vishalnayan.wordpress.com/
Code