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 > Loading Data.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-02-08, 10:47
sathish_ix sathish_ix is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Loading Data.

Hi ,

Is there any way to replace the contents of Table A to Table B without export/import option.

Both Table A and Table B already exists in the database.
Table A contian ( 80 million records) and Table b contains (250 million )
Both Tabel A and Table B has the same structure.
Contents of Table A must be replaced into Table B.


Is there any replace command available in DB2.
This is possible in single shot.

Is there any way this can be done in 24 hrs.

Please help me on this?

Thanks,
Sathish.
Reply With Quote
  #2 (permalink)  
Old 04-02-08, 11:21
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
What platform are you on?

In DB2 OS/390 I would unload the data, then load replace

But why would you want 2 copies of the same data in 2 different tables
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #3 (permalink)  
Old 04-02-08, 11:26
SuperKuper SuperKuper is offline
Registered User
 
Join Date: Apr 2008
Posts: 51
declare c1 cursor for select * from tableA with ur
load from c1 of cursor replace into tableB nonrecoverable
.
80M rows should take minutes - not 24 hours
__________________
db2topgun.com
Reply With Quote
  #4 (permalink)  
Old 04-02-08, 11:28
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by SuperKuper
declare c1 cursor for select * from tableA with ur
load from c1 of cursor replace into tableB nonrecoverable
.
80M rows should take minutes - not 24 hours
What platform do you do that on?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #5 (permalink)  
Old 04-02-08, 11:31
SuperKuper SuperKuper is offline
Registered User
 
Join Date: Apr 2008
Posts: 51
Sorry, forgot to ask about your polatform. This solution is for DB2 LUW. Where are you trying to do this?
__________________
db2topgun.com
Reply With Quote
  #6 (permalink)  
Old 04-02-08, 11:36
Brett Kaiser Brett Kaiser is offline
Window Washer
 
Join Date: Nov 2002
Location: Jersey
Posts: 10,303
Quote:
Originally Posted by SuperKuper
Sorry, forgot to ask about your polatform. This solution is for DB2 LUW. Where are you trying to do this?

What ever, that's pretty cool though

Can you do that on os/390 z/os?
__________________
Brett
8-)

It's a Great Day for America everybody!

dbforums Yak CorralRadio 'Rita
dbForums Member List
I'm Good Once as I ever was

The physical order of data in a database has no meaning.
Reply With Quote
  #7 (permalink)  
Old 04-02-08, 13:14
SuperKuper SuperKuper is offline
Registered User
 
Join Date: Apr 2008
Posts: 51
I don't think you can do it in DB2 z/OS (looking at v7 books). But you can use this method to copy tables from DB2 z/OS and many other platforms to DB2 LUW by using federated references to source tables on those platforms.
__________________
db2topgun.com
Reply With Quote
  #8 (permalink)  
Old 04-03-08, 01:41
sathish_ix sathish_ix is offline
Registered User
 
Join Date: Apr 2008
Posts: 4
Thanks for your response,

Platform is DB2 z/OS ..

May i Knw why we cant do that in DB2 z/OS ..
Reply With Quote
  #9 (permalink)  
Old 04-03-08, 02:47
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by SuperKuper
declare c1 cursor for select * from tableA with ur
load from c1 of cursor replace into tableB nonrecoverable
.
80M rows should take minutes - not 24 hours
Maybe hours, not minutes.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #10 (permalink)  
Old 04-03-08, 02:54
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by sathish_ix
Thanks for your response,

Platform is DB2 z/OS ..

May i Knw why we cant do that in DB2 z/OS ..
There is no IMPORT command (utility) on DB2 for z/OS. DB2 for z/OS and DB2 for LUW are different products.

If you do an UNLOAD and then a LOAD with LOG NO NOCOPYPEND option on DB2 z/OS, it should be able to be done within 24 hours on most systems. You can run the UNLOAD utility against the live table, or against an image copy of the tablespace.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #11 (permalink)  
Old 04-03-08, 15:54
SuperKuper SuperKuper is offline
Registered User
 
Join Date: Apr 2008
Posts: 51
Quote:
Originally Posted by Marcus_A
Maybe hours, not minutes.
Yes - this may take hours or days on Windows. Or in Oracle.
__________________
db2topgun.com
Reply With Quote
  #12 (permalink)  
Old 04-17-08, 04:30
saidulu saidulu is offline
Registered User
 
Join Date: Nov 2007
Posts: 6
This can be done using LOAD REPLACE utility from a cursor...
This method is called DB2 croos loader function.....
If you wneed I can give the syntax.........
Reply With Quote
  #13 (permalink)  
Old 04-17-08, 07:52
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
It just hit me. If both tables are the same. Then it can be literaly be done in 10 seconds or less. RENAME TABLE command

Yes, you might have to rebuild views and such, but as long as you have no RI it is not a big deal and should be faster then any form of unload/reload. Even with RI in place it should still be faster to find and rebuild them.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #14 (permalink)  
Old 04-17-08, 09:26
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
RENAME TABLE has no influence whatsoever on indexes or RIs so you don't need to rebuild them.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #15 (permalink)  
Old 04-17-08, 11:37
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Quote:
Originally Posted by stolze
RENAME TABLE has no influence whatsoever on indexes or RIs so you don't need to rebuild them.
That is not correct. Look up SQL Ref2 Rules section for the rename.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
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