Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

what is the difference between Delete and Truncate

Answer Posted / soorai ganesh

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 contraint in place.

TRUNCATE is also a logged operation, but in a 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 exist in the data pages, but the extents have been marked as empty for reuse. This is what makes TRUNCATE a faster operation to perform over DELETE.

You cannot TRUNCATE a table that has any foreign key constraints. You will have to remove the contraints, TRUNCATE the table, and reapply the contraints.

TRUNCATE will reset any identity columns to the default seed value. This means if you have a table with an identity column and you have 264 rows with a seed value of 1, your last record will have the value 264 (assuming you started with value 1) in its identity columns. After TRUNCATEing your table, when you insert a new record into the empty table, the identity column will have a value of 1. DELETE will not do this. In the same scenario, if you DELETEd your rows, when inserting a new row into the empty table, the identity column will have a value of 265.

I believe its enough to you...............

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the template in sql?

970


what is difference between view and Dip.

2403


What are types of storage modes? : sql server analysis services, ssas

1024


how to restart sql server in single user mode? How to start sql server in minimal configuration mode? : Sql server database administration

902


Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?

986


Explain about link server in sql server?

1047


How can you check the version of sql server?

1090


Can we insert data into view sql server?

920


How can you know if the row fetched from cursor is still valid in underlying table?

993


How can you insert values in multiple rows using one Insert statement?

1087


What is the difference between clustered index and primary key?

908


What is used to replicate sessions between instances in coldfusion clusters?

1062


What is the use of RDBMS?

993


Can you explain what are commit and rollback in sql?

929


What is partitioned view?

891