If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Alter table drop column

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-28-06, 19:27
dollar489 dollar489 is offline
Registered User
 
Join Date: Sep 2002
Posts: 456
Alter table drop column

Hello, I have DB2 V8 FP11 database table on AIX 5.2 which contains around 120 million rows. I need to drop two columns in the table..what is the best way to accomplish this?

Paul
Reply With Quote
  #2 (permalink)  
Old 06-29-06, 08:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Use the SYSPROC.ALTOBJ stored procedure. Look it up in the SQL Reference. If you use the Control Center to "Drop" the columns, it will call the ALTOBJ Stored procedure for you.

Andy
Reply With Quote
  #3 (permalink)  
Old 07-01-06, 09:48
dollar489 dollar489 is offline
Registered User
 
Join Date: Sep 2002
Posts: 456
Right, but as there are 120Million rows it will take a long time to accomplish the whole task. Or does anyone knows that it will not require long time for such a number of rows?

Thanks
Reply With Quote
  #4 (permalink)  
Old 07-01-06, 10:43
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
In that case it's probably simpler (or at least faster) to do a REORG (or actually an UNLOAD followed by a DROP TABLE + CREATE TABLE, followed by a LOAD), but you loose the automatic restore of everything referring the table, like indexes, views, foreign keys in other tables, etc., which you will have to restore manually.

But maybe SYSPROC.ALTOBJ is already doing just that? In that case there will not be anything faster.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #5 (permalink)  
Old 07-03-06, 08:09
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Yes, sysproc.altobj does all that work for you behind the covers. All indexes and foreign keys (except those involving the dropped column) are
reinstated. My suggestion would be to have a copy of the production system and do a trial run on that to see how long it would take.

Andy
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On