.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal

Home >> Forum >> ADO.Net >> Post New QuestionBookmark and Share Subscribe to Forum


Posted By: Rama Krishna     Posted Date: July 19, 2009    Points:2   Category :ADO.Net
what is the difference between truncate and delete commands and explain some of them

Author: Faizal             
Posted Date: July 19, 2009     Points: 5   

Hi Rama,

TRUNCATE is a DDL command whereas DELETE is a DML command. Hence DELETE operation can be rolled back, but TRUNCATE operation cannot be rolled back. WHERE clause can be used with DELETE and not with TRUNCATE.


Author: Syed Shakeer Hussain             
Posted Date: July 20, 2009     Points: 5   

When you use Truncate

1) Removes all Rows from a Table

2) Releses the storage space used by that table

3) You cannot roll back row removal when using TRUNCATE.

4) If the table is Parent of a refrential integrity constraint,you cannot truncate the TABLE.Disable the constraint before issuing the TRUNCATE statement.
5)Truncate removes all rows faster than Delete Statement.
tablename is the name of the table.
1)Delete command only removes records,it remains table structure.
2)you can use where statement usind delete command.

Author: Akhil Raj       [Moderator]      
Posted Date: July 22, 2009     Points: 5   

Faizal told correctly more ever...just see the following.so u got clear idea about usage also

If you want to quickly remove all rows of data in a table, use [TRUNCATE] command. Sample SQL statement using [TRUNCATE] command :

TRUNCATE TABLE [tablename]

All indexes, triggers, and structures still remain intact. It is faster than [DELETE] command because when using [DELETE] command, the data is removed and logs as transaction one row at a time. On the other hand, [TRUNCATE] will deallocate the entire data page in the table and reduces the number of logs activities; thus performs better compare to [DELETE] command.

Sample using [DELETE] command:

1. DELETE FROM [table name]
2. DELETE FROM [table name] WHERE [clauses]

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend