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 > one query to access multiple database on DB2 Instance

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-08, 02:53
rahul1979z rahul1979z is offline
Registered User
 
Join Date: Apr 2008
Posts: 2
Red face one query to access multiple database on DB2 Instance

Hi,

I am new to DB2 and I am having this one simple query :-

How do I access the two different databases defined in same DB2 Instance using a single query?

e.g.
I have 2 Databases DB2Member and DB2CLaims.
Table Membership in DB2Memeber database and
Table Claim_dtl in DB2Claims database.
Both Databases are running on same DB2 Instance.

Now I wanted to run a query which will get me the Membership info for all
members and Claimdtl info associated with those members.

I suppose SQL would be something like:-
Select A.MemberName, A.MemStatus, B.MemClaimDt, B.MemClaimAmt
From DB2Member.Membership as A, DB2Claims.Claim_dtl as B
Where A.MemID = B.MemID


Now I want to know, how do I do this in DB2?
I have heard of something call federation which allows querying multiple heterogenic databases e.g. Oracle, DB2 etc. Do I have to use this service? If yes , than how?

Thanks a lot in advance for your time and help.

With Cheers,
Rahul
Reply With Quote
  #2 (permalink)  
Old 04-03-08, 03:18
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
You would need to activate the database for Federated support , and then create alias' and wrappers on one of the databases (where the SQL runs) that references the other database.

See the Federated manual for details or google "db2 federated"
__________________
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
  #3 (permalink)  
Old 04-03-08, 04:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Another option to consider is not using separate databases but rather different schemas.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 04-04-08, 07:38
rahul1979z rahul1979z is offline
Registered User
 
Join Date: Apr 2008
Posts: 2
Talking

Database tables are already existing, so restructuring is not an option right now.
I think federation would do the trick for me.
Thanks a lot guys for quick reply.
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