By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,017 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,017 IT Pros & Developers. It's quick & easy.

How to delete tables completely?

P: n/a
Hi everyone.
I need to completely remove all entries in a number of tables.
Dropping the tables works fine - my only problem is, that in production
environment I don't have the right to drop the tables .. ;)

So I try to delete all entries - but experience that subsequent access to
the database (a lot of different selects and inserts invoked via java) is
much slower than it would be on dropped and new created tables. (Just as
if they weren't empty.)

My SQL looks like that:

delete from mytable;
commit;
reorg table mytable;
commit;
runstats on table myTable on all columns;
commit;
Thereafter the tables _are_ empty, but my DB2 data directory still takes
a lot more disk space than it would with newly created tables ...

Am I missing something?
Is there something concerning the indexes I should do after deletion?

I'm working on DB2 8 (8.1.0.36), but DB2 7.2 seems to behave the same way.

Thanks in advance for any hints, Robert Kersten.
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jag
try import replace from empty file

"Robert Kersten" <ke******@cs.tu-berlin.de> wrote in message
news:ci**********@news.cs.tu-berlin.de...
Hi everyone.
I need to completely remove all entries in a number of tables.
Dropping the tables works fine - my only problem is, that in production
environment I don't have the right to drop the tables .. ;)

So I try to delete all entries - but experience that subsequent access to
the database (a lot of different selects and inserts invoked via java) is
much slower than it would be on dropped and new created tables. (Just as
if they weren't empty.)

My SQL looks like that:

delete from mytable;
commit;
reorg table mytable;
commit;
runstats on table myTable on all columns;
commit;
Thereafter the tables _are_ empty, but my DB2 data directory still takes
a lot more disk space than it would with newly created tables ...

Am I missing something?
Is there something concerning the indexes I should do after deletion?

I'm working on DB2 8 (8.1.0.36), but DB2 7.2 seems to behave the same way.

Thanks in advance for any hints, Robert Kersten.

Nov 12 '05 #2

P: n/a
Robert,

why not simply

LOAD FROM /dev/null of del replace into tablename NONRECOVERABLE
- This truncates the table very quickly, not sure if
it reclaims space updates stats by default?

This has the added advantage that you don't have to
perform deletes in the correct RI order.
(though you will have to do a SET INTEGRITY afterwards)

OK
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.