473,624 Members | 2,135 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 16040
ej****@perrierg roup.com (Ed) wrote in message news:<d7******* *************** ****@posting.go ogle.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
7422
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 function of a log. It has a hit of approximately 2 records a second. Such a large volume of data eats into our tablespace and we have decided to summarize the data in this table. So we have a function that summarizes the data, inserts it into a...
3
4522
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 like to issue a truncate table statement, but with millions of rows we are a bit wary of how this will affect server performance. The alternative is to delete is stages using rowcount but of course this will generate a large amount of logging....
5
3102
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 deletions in the transaction log. It can't be used with tables referenced by FOREIGN KEY constraints, and it invalidates the transaction log for the entire database. Once the transaction log has been invalidated, it can't be backed up until the...
9
14687
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 "load" and is fast? Thanks, Sumanth
6
13108
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 not logged initially with empty table My question is: 1. Do we have to connect to the database with auto-commit off every
8
8089
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 something like that? Thank you for all answers Stefan
14
12277
by: Sala | last post by:
Hi I want to truncate all data in database ... pls help me how i ll truncate?
10
13878
by: Troels Arvin | last post by:
Hello, Until this date, I believed that DB2 has no TRUNCATE TABLE command. But then I came across http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.admin.doc/doc/c0023297.htm where it says: After an ALTER TABLE statement containing REORG-recommended operations, you can execute only the following statements on a table:
8
7695
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 a procedure to drop the storage of a table used... when its record count exceeds 500. BEGIN i:= 0; FOR CC IN NLD LOOP
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8172
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8677
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8620
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.