1
Reply

what is the difference between Delete and Truncate command in SQL

ankit kumar

ankit kumar

13y
6.2k
0
Reply

    Delete -is a logged operation on a per row basis , this means that the deletion of each row gets logged and physically deleted. You can delete any row that will not violate a constraint,while leaving the foreign key or any other constraint in place.
    Truncate-
    is also a logged operation but in different way.Truncate logs the deallocation of the data pages in which the data exists. The deallocation of  data pages means that your data rows still actually
    exists in the data pages but the extend have been marked as empty for  reuse this is what makes truncate a faster operation over delete. you can not truncate a table that has any foreign key  constraint . you will have to remove the constraint , truncate the table and reapply the
    constraint..