Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between truncate and delete command in sql query [duplicate]

Tags:

sql-server

Possible Duplicate:
What’s the difference between TRUNCATE and DELETE in SQL

what is the difference between truncate and delete command in sql query

like image 544
kailashnkute Avatar asked Dec 14 '25 12:12

kailashnkute


1 Answers

Delete marks each row as deleted (ghost record) and logs the individual row being deleted in the transaction log (in fully logged mode) or marks the page as being altered (in bulk logged). Delete permits a where clause, allowing the rows to be deleted, filtered.

Truncate removes the link from the table to the IAM and drops it on the floor, logging (bulk and full) the fact that it dropped the IAM, freeing up the space. Truncate removes all rows for the table, and can not be filtered.

like image 152
Andrew Avatar answered Dec 16 '25 04:12

Andrew



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!