March 20, 2013 at 10:11 pm
Comments posted to this topic are about the item Delete v Truncate
Best,
Naseer Ahmad
SQL Server DBA
March 20, 2013 at 10:23 pm
"It" refers to Truncate .
It's a DDL , Data definition language - why ? I think because It resets the identity, that is a database object property change. [because, it does delete so should qualify for DML too ..]
And It doesn't fire trigger , because deletion is actually page deallocations in case of truncate , not individual row deletions .
thanks for the question
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
March 20, 2013 at 10:59 pm
Thanks for recalling the basics.
Still I have question, why it has been called as DDL command?
--
Dineshbabu
Desire to learn new things..
March 20, 2013 at 11:19 pm
Dineshbabu (3/20/2013)
Thanks for recalling the basics.Still I have question, why it has been called as DDL command?
I think due to different behavior of truncate command, it's consider as DDL Command.
check the below link for more information
But anyway, good question and recall basic again. Good start of day. 🙂
Thanks
Vinay Kumar
-----------------------------------------------------------------
Keep Learning - Keep Growing !!!
March 21, 2013 at 12:30 am
Good basic question...
Thanks Naseer 🙂
_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
March 21, 2013 at 1:45 am
Thanks for the question.
March 21, 2013 at 2:34 am
Interesting - I went with DML, but thinking about it now, it seems more like a hybrid that's both DDL and DML.
Can you fire a DDL trigger when a TRUNCATE TABLE takes place? I don't think it's in the DDL event list.
MS docs sometimes refer to it as a DML operation as well:
"Some data manipulation language (DML) operations, such as table truncation, use Sch-M locks to prevent access to affected tables by concurrent operations." -- http://msdn.microsoft.com/en-us/library/ms175519.aspx
Is there an official list of DDL operations or is its DDL-ness decided by community consensus? 🙂
March 21, 2013 at 2:35 am
Thanks for the question - good reminder of the basics.
It appears that quite a few here needed reminding of the differences - 40% wrong at the moment.
I wonder how much higher it would have been if you asked which are logged in the question :w00t:
-------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
March 21, 2013 at 3:43 am
good one. thank you for posting.
I guess it is a long fight because neither way it cannot be proved 100% that it is a DML or DDL depending on the proper action it executes underneath; this link says otherwise http://msdn.microsoft.com/en-us/library/ms175519(v=sql.105).aspx (see under the schema locks section)
(This will be another interesting discussion )
For me it is a DDL (based of my feelings :hehe:)
- it is the quickest way get the data deleted on the single table
- like s/d/u/i statements truncate is not commonly used like others
- in general practice, as truncate removes all the records and no one wants to remove all the records from the table, only if any exceptional case where an SA(sql) or DBA wants to use on some table they think
- in the architecture (generally saying) most of the tables are connected with PK/FK, so again if some one wants to use truncate why would they remove/delete the relationship and then use truncate and then put the relationship back just the sake of deleting?
- as the truncate can be used on single table; so that means that table would be a standalone and it may or may not be storing some kind of data where it is less important like archived log activity of the user stored on a separate table on a different file_group... something like that. (I am not questioning the high standard of the design and how properly each object is configured to use, but just a low point making based on my feelings)
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
March 21, 2013 at 3:44 am
jpentz99 (3/21/2013)
...MS docs sometimes refer to it as a DML operation as well:
"Some data manipulation language (DML) operations, such as table truncation, use Sch-M locks to prevent access to affected tables by concurrent operations." -- http://msdn.microsoft.com/en-us/library/ms175519.aspx
Is there an official list of DDL operations or is its DDL-ness decided by community consensus? 🙂
+1 (i actually posted the same link... reposted by me.... 😀 )
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
March 21, 2013 at 3:46 am
Two pints for this?
Wow!
March 21, 2013 at 4:08 am
Easy one, thanks.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
March 21, 2013 at 4:13 am
Raghavendra Mudugal (3/21/2013)
...
- in general practice, as truncate removes all the records and no one wants to remove all the records from the table, only if any exceptional case where an SA(sql) or DBA wants to use on some table they think
- in the architecture (generally saying) most of the tables are connected with PK/FK, so again if some one wants to use truncate why would they remove/delete the relationship and then use truncate and then put the relationship back just the sake of deleting?
- as the truncate can be used on single table; so that means that table would be a standalone and it may or may not be storing some kind of data where it is less important like archived log activity of the user stored on a separate table on a different file_group... something like that. (I am not questioning the high standard of the design and how properly each object is configured to use, but just a low point making based on my feelings)
I have most commonly used truncate on import tables that are holding data to be munged into other places and so unrelated to anything (perhaps as part of SSIS packages or similar).
cheers,
Iain
March 21, 2013 at 4:48 am
Thanks for the question. An easy one, but I did refer to BOL to make sure before I answered.
March 21, 2013 at 5:08 am
call.copse (3/21/2013)
Raghavendra Mudugal (3/21/2013)
...
- in general practice, as truncate removes all the records and no one wants to remove all the records from the table, only if any exceptional case where an SA(sql) or DBA wants to use on some table they think
- in the architecture (generally saying) most of the tables are connected with PK/FK, so again if some one wants to use truncate why would they remove/delete the relationship and then use truncate and then put the relationship back just the sake of deleting?
- as the truncate can be used on single table; so that means that table would be a standalone and it may or may not be storing some kind of data where it is less important like archived log activity of the user stored on a separate table on a different file_group... something like that. (I am not questioning the high standard of the design and how properly each object is configured to use, but just a low point making based on my feelings)
I have most commonly used truncate on import tables that are holding data to be munged into other places and so unrelated to anything (perhaps as part of SSIS packages or similar).
cheers,
Iain
+1
Staging tables ... 🙂
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
Viewing 15 posts - 1 through 15 (of 44 total)
You must be logged in to reply to this topic. Login to reply