Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am a beginner in sql and I have some confusiom abou truncate. My question is how the truncate command is different from delete? Which one is best for query? Please help me or give me any link where I can learn about it.

Thanks in advance.
Posted
Updated 19-Dec-10 23:15pm
v2
Comments
JF2015 20-Dec-10 5:15am    
Edited for spelling and grammar.

The actual difference between Delete and Truncate Table command for delete table is that
a) A Truncate table statement is executed much faster than delete table.
b) Truncate table does not support the where clause.
c) Truncate Table Statement does not fire a trigger. When truncate is used, the deleted rows are not entered in the transaction log.
d) You can also not use Truncate Table statement for delete table which is referenced by Foreign key constraint.

and it depends upon query which is better between Delete and Truncate Table Command. if you want to delete all table means not want to use selected value from table then in that case Truncate Tablewill be the best

For more details navigate the given link
difference between DELETE and TRUNCATE[^]

Hope it will works for you.
 
Share this answer
 
Comments
Dalek Dave 20-Dec-10 5:51am    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900