Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««12345

TRUNCATE Expand / Collapse
Author
Message
Posted Wednesday, April 7, 2010 1:40 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, May 9, 2014 12:47 AM
Points: 3,448, Visits: 4,407
Peter Trast (4/7/2010)
vk-kirov (4/7/2010)
Maybe because TRUNCATE manipulates metadata, not data? (It's my suggestion only)

DOES truncate delete metadata??? (I am thinking no).

You are right. TRUNCATE does not delete metadata, it manipulates metadata. But... what is the relation between your (rhetorical) question and my suggestion?

Let's see what exactly TRUNCATE does (http://msdn.microsoft.com/en-us/library/ms177570.aspx):
TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log.
TRUNCATE TABLE always locks the table and page but not each row.

Page deallocation is surely a metadata manipulation. Data remain intact in their comfortable pages... until the time comes.

Peter Trast (4/7/2010)
I guess I was suggesting that the person who authored that webpage didn't know what he was talking about

Perhaps the definitions of DML/DDL on that page are slightly inaccurate.
But there's a dramatical difference between DML and DDL statements in Oracle. A DDL statement is committed implicitly and immediately, and cannot be rolled back. This is why it's very important to know the classification of the SQL commands.
Happily, we are using SQL Server and can roll back any DDL command; so I consider the question "is TRUNCATE a DDL statement or not?" as a theoretical question. Happily, Paul gave the straightforward answer to this question: it's a DML statement because Microsoft documentation says it. Other arguments may be (and have been) debated at least on two forum pages. Even using the de-duck-tion methods
Post #898942
« Prev Topic | Next Topic »

Add to briefcase «««12345

Permissions Expand / Collapse