C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Difference between DELETE and TRUNCATE COmmand


Posted Date: 01 Oct 2008    Resource Type: Articles    Category: Databases

Posted By: Athira Appukuttan       Member Level: Diamond
Rating:     Points: 5



Difference between DELETE and TRUNCATE COmmand

Delete command removes the rows from a table based on the condition thate we provide with a WHERE clause.Truncate will actually remove all the rows from a table and there will be no data in the table after we can run the truncate command.

Truncate:
Truncate is faster and uses fewer system and transaction log resources than Delete.
Truncate removes the data by deallocationg the data pages used to store the tables's
data,and only the page deallocations are recorded in the transaction log.
Truncate removes all rows froma table ,but the table structure and its columns ,constraints ,indexes and so on remain.The counter used by an idetity for new rows is reset to the seed for the column.
You cannot use Truncate table on a tbale referenced by a Foreign key constant.Because Truncate table is not logged,it cannot activate a trigger.
Truncate cannot be rolled back.
Truncate is dll command.
Truncate resets identity of the table.

Delete:
Delete removes rows one at a time and records an entry in the transaction log for each deleted row.
If you want to retain the identity counter,use delete instead.If u want to remove table definition and its data,use the DROP TABLE statement.
Delete can be used with or without a WHERE clause.
Delete activate triggers.
Delete can be rolled back.
Delete is DML command.
Delete does not reset identity of the table




Responses

Author: Roopesh Babu Valluru    14 Oct 2008Member Level: Gold   Points : 1
good article man...

i knew many but it helped to know all ... :)

Thx a lot....


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Difference between DELETE and TRUNCATE COmmand  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Understand Views
Previous Resource: DBCC FreeProcCache & DBCC DROPCLEANBUFFERS
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

masks masks masks

Contact Us    Privacy Policy    Terms Of Use