473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Truncate Table vs. Drop Table

Ed
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?

Ed
Jul 20 '05 #1
2 16020
ej****@perriergroup.com (Ed) wrote in message news:<d7**************************@posting.google. com>...
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?

Ed


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.

Simon
Jul 20 '05 #2
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 ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ritu | last post by:
Hello Folks, I chanced upon this newsgroup in my search for a solution to a problem I am facing. I hope someone can give me a pointer. I have a table in an Oracle 8i database that performs the...
3
by: martin | last post by:
Hi, We have a heavily used production server and a table which logs every hit on a web site. This table has grown large over time and we want to clear it down as efficiently as possible. We would...
5
by: ronin 47th | last post by:
Hi group, In one of the books 'Gurus Guide to Transact SQL' i found this info: ------------------------------------------------------------ TRUNCATE TABLE empties a table without logging row...
9
by: Sumanth | last post by:
Are there any implementations of truncate in db2. Is it going to be implemented in the future? Is there an alternate way of doing a truncate of a table that has a high record count without using...
6
by: pramod | last post by:
Hi I know we can truncate a table in DB2 by first creating it with NOT LOGGED INITIALLY option. and when we need to truncate it, run the following command alter table <table name> activate...
8
by: Stefan | last post by:
Hi all, two questions: - is there a way to call the INSERT-Statement from Java (JDBC). (import from file of del replace into table) - in db2 there is no truncate-statement, is it? Is in db2...
14
by: Sala | last post by:
Hi I want to truncate all data in database ... pls help me how i ll truncate?
10
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across...
8
by: ananthaisin | last post by:
How to reduce the table size for any table while using truncate or delete statements. In oracle 8i it was truncating the storage space but in 10g it is not .... I have given truncate statement in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.