What is difference between TRUNCATE and DELETE statement
Answer Posted / manub22
–> DELETE:
1. Removes Some or All rows from a table.
2. A WHERE clause can be used to remove some rows. If no WHERE condition is specified, all rows will be removed.
3. Causes all DELETE triggers on the table to fire.
–> TRUNCATE:
1. Removes All rows from a table.
2. Does not require a WHERE clause, so you can not filter rows while Truncating.
3. IDENTITY columns are re-seeded on this operation, if no seed was defined then the default value 1 is used.
4. No Triggers are fired on this operation because it does not operate on individual rows.
Check more differences b/w DELETE & TRUNCATE here: http://sqlwithmanoj.com/2009/02/22/difference-between-truncate-delete-and-drop-commands/
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is a system database and what is a user database?
What is attribute hierarchy? : sql server analysis services, ssas
How can we migrate from SQL server to SQL Azure?
What is 2nf in normalization?
What is a full text index?
How to create a view on an existing table in ms sql server?
What are the different normalization forms?
Can a stored procedure call itself or recursive stored procedure? How much level sp nesting is possible?
How many clustered indexes can be created on a table? I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?
What is primary key, unique key, and foreign key?
Tell me what do we need queues in sql service broker?
Why use stored procedures in sql server?
What is cte (common table expression)?
What is the difference between Triggers and Stored Procedure?
Explain the properties of subqueries in sql server?