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 > moving data between tables in different databases

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-09, 04:08
Howardw Howardw is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
moving data between tables in different databases

I have a windows server with an instance of DB2. I have a database holding data in tables in non normalised form.

I need to copy and insert data from these tables to a database with tables in a normalised form.

Some tables will copy one for one. Can i use the select/insert query form to load these tables.

Some tables will require some manipulation, joining reference tables to create data in the new tables.

can this be done between tables in different databases on the same instance of DB2.

My problem as i see it is - when you sign on in windows you need to access the database using a connection spcefic to the database.

Is it possible to connect on the same instance to 2 different databases using the same sign on.

or

do i need to setup a federated database environment to join the databases together.

any answer or suggestion gratefully appreciated
Reply With Quote
  #2 (permalink)  
Old 11-11-09, 04:22
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
I can think of a few options :
a) export from the source (using the target's table defn) and load into the target

b) define federation on the target to point to the source database and use Load from cursor.

c) Backup the source db and restore. Define target tables in it, 'load from cursor' the data to the target tables and drop the source tables.

d) ....

e) ....

Which one you adopt, depends on a number of factors - is the source heavily used, is the target currently in use, is it one-off or a regular one, is this incremental or full etc etc

Cheers
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 11-11-09, 09:16
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
you did not mention version of DB2 you are using.

you might want to read a document called Data Movement Utilities Guide for your DB2 version. It has all the info there (db2move, etc.)

from my experience i'd prefer option c) suggested by Sathyaram
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 11-11-09, 10:18
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
I did not suggest db2move because the source and the target table structures are not the same

Quote:
Originally Posted by MarkhamDBA View Post
you did not mention version of DB2 you are using.

you might want to read a document called Data Movement Utilities Guide for your DB2 version. It has all the info there (db2move, etc.)

from my experience i'd prefer option c) suggested by Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #5 (permalink)  
Old 11-12-09, 03:29
Howardw Howardw is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
I will be using Db2 9.5 on windows server 2005.

My question is - can i join two tables in 2 different databases on the same instance of DB2 without having to setup Federation on the server.

Can I insert data from one table in 1 database to another table in another database using SQL without using Federation on the same instance of DB2.
Reply With Quote
  #6 (permalink)  
Old 11-12-09, 04:39
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Two tables from different databases can be accessed using Federation only.

The federation can be setup on one of these databases to access the other one
or
a separate database can be used to setup federation to access both the databases.





Quote:
Originally Posted by Howardw View Post
I will be using Db2 9.5 on windows server 2005.

My question is - can i join two tables in 2 different databases on the same instance of DB2 without having to setup Federation on the server.

Can I insert data from one table in 1 database to another table in another database using SQL without using Federation on the same instance of DB2.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 11-12-09, 04:47
Howardw Howardw is offline
Registered User
 
Join Date: Nov 2009
Posts: 18
thanks Sathyaram

this answer is what i needed to know.

I can now plan what I need to do and how much work will be involved.
Reply With Quote
  #8 (permalink)  
Old 11-12-09, 06:59
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
Quote:
Originally Posted by Howardw View Post
I will be using Db2 9.5 on windows server 2005.
Did Bill cook that specially for you? We mortals have to choose between server 2003 and server 2008
Reply With Quote
  #9 (permalink)  
Old 12-03-09, 10:13
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Quote:
Originally Posted by dr_te_z View Post
Did Bill cook that specially for you? We mortals have to choose between server 2003 and server 2008
Nice joke ! keep it up
Reply With Quote
  #10 (permalink)  
Old 12-03-09, 10:16
DBFinder DBFinder is offline
Registered User
 
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
Quote:
Originally Posted by Howardw View Post
Is it possible to connect on the same instance to 2 different databases using the same sign on.

or

do i need to setup a federated database environment to join the databases together.

any answer or suggestion gratefully appreciated
If the issue is simply transfer/compare data, simplest is export and Load.
Also I used java program to connect to two DBs for comparing same structure table between two DBs.

DBFinder
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