+ 5
what is the difference between delete and truncate commands?
in simple words
5 Answers
+ 9
TRUNCATE is DDL command . it is used to remove All rows in the table where as DELETE command is DML command. it is used to remove specific rows in the table
+ 3
TRUNCATE
Removes all rows 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.
DELETE
Command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation, you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.
+ 2
delete and truncate comments similar but some different delete command remove rows one bye one it take time for large databases and truncate command remove structure of that table and create a new structure of that table
+ 1
and in addition of @sonali madam :) : after delete you can use commit and rollback but that's not case with truncate.
0
truncate releases the storage space immediately, whereas delete will only remove the records , but the space used by deleted records cannot be utilised until table is defragmented or rebuild