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 > Any Faster Way to Add Columns?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-11-06, 05:27
wilsonang wilsonang is offline
Registered User
 
Join Date: Apr 2006
Posts: 2
Any Faster Way to Add Columns?

It takes almost 3 hours to add 20 odd columns to a table of about 8 million records. Each operation Alter Table Add Column takes about 7 minutes, so 20 odd such operations take 3 hours.

A faster way I think of is :
To add columns to table A of 8 million records,
1. create a temporary table B with schema same as table A.
2. copy all data from table A to table B.
3. CLRPFM table A
4. alter table A.
5. copy all data from table B to table A.

But this method seems cumbersome and need to handle foreign keys etc.

Is there any better and faster way to accomplish the task?

Thank you!

DB2 on AS/400 (V5R1)
Running on 5250 Session.
Reply With Quote
  #2 (permalink)  
Old 04-11-06, 05:32
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Why not add all 20 columns in one statement ?

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 04-11-06, 21:18
wilsonang wilsonang is offline
Registered User
 
Join Date: Apr 2006
Posts: 2
Oops, learn the syntax now. Thank you!
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