What is the Difference Between TRUNCATE & DELETE Clauses in SQL Server
» July 3, 2010 |
Labels:
Differences,
SQL Server,
T-SQL
|
Qns by Labels |
|||||||
- TRUNCATE is a DDL (Data Definition Language) command, whereas DELETE is a DML (Data Manipulation Language) command.
- TRUNCATE removes all the records from a table without making a log entry for individual row deletions (Does make log entries about data page deallocation etc, which can be used for ROLLBACK of a TRUNCATE command), whereas DELETE removes all or selected records (based on absence or presence of a WHERE condition) from a table by making a log entry for individual row deletion. Hence TRUNCATE is faster than DELETE.
- TRUNCATE removes all the records from a table and a WHERE clause or filter condition cannot be used with TRUNCATE, whereas DELETE can remove selected records or all records based on whether a WHERE clause (Optional) is used or not used respectively.
- TRUNCATE cannot be used on a table if it satisfies one of the following conditions:
- Table is referenced by one of more FOREIGN KEY constraints
- Table is marked / enabled for Replication
- TRUNCATE resets IDENTITY in any of the columns in a table, whereas DELETE does not reset the IDENTITY.
4 comments:
Nice Comparison!
Great Blog Thanks.
Here You Can Find Your First Round Intreview question For Job .
SSRS interview questions
Nice Interview Questions
SQL Interview Questions
BPO Interview Questions
C Interview Questions
Spring Interview Questions
Iot Interview Questions
HTML5 Interview Questions
Microsoft BI Interview Questions
This post is really nice and informative. The explanation given is really comprehensive and informative..
Web Designing Training in Chennai
Web Designing Course in Chennai
Web Designing Training in Bangalore
Web Designing Course in Bangalore
Web Designing Training in Hyderabad
Web Designing Course in Hyderabad
Web Designing Training in Coimbatore
Web Designing Training
Web Designing Online Training
Post a Comment