Re: Difference Between Truncate and Delete
From: Kalen Delaney (replies_at_public_newsgroups.com)
Date: 08/01/04
- Next message: bmurtha: "best way to group by day?"
- Previous message: Hassan: "stored procedure to capture identity values"
- In reply to: me: "Re: Difference Between Truncate and Delete"
- Next in thread: Paul Connelly: "Re: Difference Between Truncate and Delete"
- Reply: Paul Connelly: "Re: Difference Between Truncate and Delete"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 31 Jul 2004 22:54:40 -0700
Actually, TRUNCATE is logged, but what is logged is not the individual rows,
but the page and extent deallocations. It is more than simply moving a file
pointer, as tables are NOT files.
TRUNCATE can be inside a transaction, and if the transaction is rolled back,
the deallocated pages are remarked as allocated.
It is not true that TRUNCATE is practically instantaneous, although it can
seem that way compared to DELETE of individual rows.One of my clients had a
table so big that it took over 20 minutes to do a TRUNCATE, but we never
timed a DELETE.
-- HTH ---------------- Kalen Delaney SQL Server MVP www.SolidQualityLearning.com "me" <jscott56@teranews.com> wrote in message news:HN_Oc.78007$vJ6.76709@cyclops.nntpserver.com... > delete causes the rows to be deleted, as part of a transaction, and is > logged to the log file. > > truncate resets the end of file pointer, effectively removing reference to > all the rows. No transaction log entry, and no opportunity to recover the > data from the log. > > truncate will run much much faster on tables with many rows than will the > delete. Its nearly instantanious. > > > "Panks" <agarwalp@eeism.com> wrote in message > news:OotXT97aEHA.1840@TK2MSFTNGP11.phx.gbl... > > What is the difference between Truncate and delete Statements > > > > Eg > > > > DELETE from table1 -- deletes all the rows , so does TRUNCATE table > table1 > > > > > >
- Next message: bmurtha: "best way to group by day?"
- Previous message: Hassan: "stored procedure to capture identity values"
- In reply to: me: "Re: Difference Between Truncate and Delete"
- Next in thread: Paul Connelly: "Re: Difference Between Truncate and Delete"
- Reply: Paul Connelly: "Re: Difference Between Truncate and Delete"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|