Groups | Blog | Home
all groups > sql server (alternate) > january 2004 >

sql server (alternate) : Truncate Table vs. Drop Table


ejones NO[at]SPAM perriergroup.com
1/14/2004 10:59:45 AM
I am trying to get some information to compare and contrast the
Truncate Table function and the Drop Table function. I know that
using Truncate Table is faster and saves the structure of the table
while the Drop Table will delete the table totally (data and
structure). My question is whether using one function over the other
will use up more capacity on the server?

sql NO[at]SPAM hayes.ch
1/15/2004 12:56:31 AM
[quoted text, click to view]

A quick test (on a smallish table) suggests that DROP TABLE requires
more CPU and I/O. I would guess this is because not only are the
extents deallocated (which also happens with TRUNCATE TABLE), but the
metadata about the table and indexes in sysobjects, syscolumns etc.
has to be removed.

Personally, I'd say that in most cases, the work required to rebuild a
table (retrieve and execute scripts for the table plus constraints,
triggers etc) is probably a bigger consideration. But I'm more or less
guessing - the only way to get a clear answer for your situation is to
test it and see.

Paul Scotchford
5/13/2004 3:46:37 AM
IMHO ... Well DROP Table is good if it is a big table that has indexes
and you plan to load it up with data (eg. 100's thousands of rows)
frequently. Dropping the table , loading it and then applying the
indexes appears faster, and you can script that of course.

As where truncate is a quick delete of all rows etc from the table.

So depending on your requirements Id advise benchmarking both mechanisms
for the table that you want to work with.





*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button