Message-ID: <3C5B6A00.2020408@hotmail.com>
From: gl <jogret@hotmail.com>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
X-Accept-Language: en-us
MIME-Version: 1.0
Newsgroups: comp.database.oracle,comp.databases.oracle.server,comp.databases.oracle
Subject: Re: TRUNCATE v DROP TABLE question
References: <nhtv4u0koeahbec0jl0gbarhs9e41k98s4@4ax.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 53
Date: Sat, 02 Feb 2002 04:14:16 GMT
NNTP-Posting-Host: 68.60.208.222
X-Complaints-To: abuse@home.net
X-Trace: news2.rdc1.mi.home.com 1012623256 68.60.208.222 (Fri, 01 Feb 2002 20:14:16 PST)
NNTP-Posting-Date: Fri, 01 Feb 2002 20:14:16 PST
Organization: Excite@Home - The Leader in Broadband http://home.com/faster


Of the first two choices, I would do the truncate.  When you truncate a 
table, all rows of data is just dropped.  The advantage here is that the 
data does not go through the rollback so there is a performance boost. 
 However, this also means the data is non-recoverable and immediate 
(it's DDL).  The truncate also leaves all the table structures (columns, 
indexes, extents, etc..) behind (I believe this includes the high water 
mark too).   Please keep in mind, whether you delete or truncate, you 
periodically have to rebuild your indexes.  I use the truncate method 
and afterwards I always rebuild the indexes.  Another thing you might 
have to do is disable the constraints.

Now doing the drop table would be very close to the truncate (DDL also), 
except it will do one other thing, it will remove all the structures. 
 That means it will release all the extents that are allocated to the 
table as well as the indexes, and the data will go the same route as the 
truncate (non-recoverable & immediate).  The bad thing with this that 
everything in the tablespace will be release, and when you go redefining 
the table, you'll get extents that are available and not necessarily 
what was used last.  This could lead to a fragmentation problem in your 
tablespace.  This plus the fact you're forcing the DB to re-define the 
table everytime (causing extra overhead), could lead to some performance 
issues in the future.  

Good luck,
jogret.....


harry wrote:

>Using Oracle 8i on NT Server 4 (sp6a)
>
>I have a table that gets populated from scratch every week or so using a "CREATE TABLE tablename as
>SELECT ..." statement.
>
>As the table is very large its a bit tricky to try all different speed tests on it so I was
>wondering if somebody could tell me if this is the quickest way to do this?
>
>Should I -
>
>1. use a "TRUNCATE TABLE" statement & use a "INSERT INTO" instead? - will the indexes automatically
>be dropped aswell? - I don't want them active when doing an INSERT - do I have to recreate them
>after?
>
>2. Use "DROP TABLE tablename  cascade constraints" statement? - does this remove indexes aswell?
>
>3. any other ideas?
>
>Many thanks
>
>HArry
>
>
 

