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 > DB2 -- how to query if using 2 different databases

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-02-04, 07:49
thien0809 thien0809 is offline
Registered User
 
Join Date: Apr 2004
Posts: 33
Question DB2 -- how to query if using 2 different databases

I have 2 databases one is called “E” and one is called “S”. In database E, I have a table called “Employee” and in database “S”, I have a table called “Event”. I need to get FName and Lname from database E, table Employee. How can I do the query? Appreciate it. Thanks a lot.
Reply With Quote
  #2 (permalink)  
Old 12-02-04, 07:55
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Look into "Federation". This will make it appear that the tables of one database are part of another. You can then do normal SQL including joins on tables in the different actual DBs.

HTH

Andy
Reply With Quote
  #3 (permalink)  
Old 12-02-04, 08:17
thien0809 thien0809 is offline
Registered User
 
Join Date: Apr 2004
Posts: 33
Question DB2 - Federation

Quote:
Originally Posted by ARWinner
Look into "Federation". This will make it appear that the tables of one database are part of another. You can then do normal SQL including joins on tables in the different actual DBs.

HTH

Andy
Andy,

This for your reply.

Is this something that the DBA has to do it at the server site or something that i can do as in my own PC (developement site)???? Thanks.
Reply With Quote
  #4 (permalink)  
Old 12-02-04, 08:19
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The DBA has to set it up on the servers.

Andy
Reply With Quote
  #5 (permalink)  
Old 12-02-04, 08:23
thien0809 thien0809 is offline
Registered User
 
Join Date: Apr 2004
Posts: 33
Question

Quote:
Originally Posted by ARWinner
The DBA has to set it up on the servers.

Andy
The two or more databases are under the same server (just has more than one databases to seperate each big application). Is the method still the same thing?????? I have just read some about "Federation", they talk more about databases in many different servers (db2, oracle, and etc). Thanks.
Reply With Quote
  #6 (permalink)  
Old 12-02-04, 08:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
It does not matter if the databases are on the same server or different server, the only way to access both dbs in a single SQL is through Federation.

Andy
Reply With Quote
  #7 (permalink)  
Old 12-02-04, 08:46
thien0809 thien0809 is offline
Registered User
 
Join Date: Apr 2004
Posts: 33
Quote:
Originally Posted by ARWinner
It does not matter if the databases are on the same server or different server, the only way to access both dbs in a single SQL is through Federation.

Andy
Thanks Andy. It helps a lot. At least I know now where to search more information.
Reply With Quote
  #8 (permalink)  
Old 12-02-04, 11:58
przytula przytula is offline
Registered User
 
Join Date: Nov 2004
Posts: 374
federated

in short :
db2 update dbm cfg using federated yes
db2 create wrapper db2drda
db2 create server mapping xxx .....
db2 create user mapping for server xxxx
db2 create nickname schema1.name1 for db1.schema1.name1
db2 select * from schema1.name1 : as for a local table
Best Regards, Guy Przytula
__________________
Best Regards, Guy Przytula
DB2/ORA/SQL Services
DB2 DBA & Advanced DBA Certified
DB2 Dprop Certified
http://users.skynet.be/przytula/dbss.html
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