Geeks Talk

Prepare for your Next Interview




Why Truncate is DDL?

This is a discussion on Why Truncate is DDL? within the SQL Server forums, part of the Databases category; The Delete command is a DML statement because it deletes data from table The Truncate command is also Delete the Records from tables. But how the Truncate command comes under ...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 06-08-2007
Contributing Member
 
Join Date: Jun 2007
Location: Bangalore
Posts: 32
Thanks: 3
Thanked 20 Times in 5 Posts
vcyogi is on a distinguished road
Question Why Truncate is DDL?

The Delete command is a DML statement because it deletes data from table

The Truncate command is also Delete the Records from tables.

But how the Truncate command comes under DDL Statement??
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-08-2007
Junior Member
 
Join Date: May 2007
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
SQLTweety is on a distinguished road
Re: Why Truncate is DDL?

Where DELETE statement deletes rows from table matching specifications in WHERE clause .
TRUNCATE deallocates memory page(s) allocated for the specific table in memory and hence it is a DDL statement rather than DML.

Ofcourse DELETE can be executed with out using WHERE calause to delete all the rows , however the page(s) are not deallocated .

Additional info : DELETE statement is logged operation and hence can be rolled back where as TRUNCATE is not and hence can not be rolled back

HTH

Regards,
Reply With Quote
The Following User Says Thank You to SQLTweety For This Useful Post:
  #3 (permalink)  
Old 06-08-2007
Expert Member
 
Join Date: Nov 2006
Location: Hyd-IND
Posts: 523
Thanks: 1
Thanked 55 Times in 46 Posts
sutnarcha is on a distinguished road
Re: Why Truncate is DDL?

Good answer from SQLTweety. Deserves applauds.
__________________
Lack of WILL POWER has caused more failure than
lack of INTELLIGENCE or ABILITY.

-sutnarcha-
Reply With Quote
  #4 (permalink)  
Old 06-08-2007
Junior Member
 
Join Date: May 2007
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
SQLTweety is on a distinguished road
Re: Why Truncate is DDL?

Glad I could help


Keep inventing.

Regards.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
difference between delete and truncate bvani MY SQL 18 12-13-2007 06:03 AM


All times are GMT -4. The time now is 01:42 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved