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 view that spans multiple databases

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-28-09, 04:46
shaidhb shaidhb is offline
Registered User
 
Join Date: Sep 2009
Posts: 3
Post DB2 view that spans multiple databases

Hi,

Could someone please advice on the correct syntax for creating a View in DB2 that will access other db2 databases in the same server.

i have tried the following:

CREATE VIEW testview AS
SELECT
table1.col2,
table3.col6
FROM
Database.Schema.table AS mytable;

this code returns an error "undefined name", any assistance in this regard would be greatly appreciated.

Thank you in advance.

Shai.
Reply With Quote
  #2 (permalink)  
Old 09-28-09, 05:23
dr_te_z dr_te_z is offline
Registered User
 
Join Date: Jan 2009
Location: Zoetermeer, Holland
Posts: 555
google for "federated". In the from-clause you must code nicknames instead of tablenames.
(db2girl wrote a good piece in this forum a few weeks ago)
Reply With Quote
  #3 (permalink)  
Old 09-28-09, 06:13
shaidhb shaidhb is offline
Registered User
 
Join Date: Sep 2009
Posts: 3
Post

Hi dr te z,

I was hoping you could supply some sample code on how to go about this or perhaps send me a link to a thread that db2girl posted a few weeks ago.

thank you though, i did google federated and i'm going through some of the info i got.

thanx!
Reply With Quote
  #4 (permalink)  
Old 09-28-09, 06:28
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
If you are using DB2 z/OS, you don't need federation because there a database is pretty much only a qualifier for tablespaces.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 09-28-09, 06:48
shaidhb shaidhb is offline
Registered User
 
Join Date: Sep 2009
Posts: 3
db2 view spans multiple databases

Hi Stolze,

could you please supply sample code that will allow the achievement of this, if possible.

thanx!

shai.
Reply With Quote
  #6 (permalink)  
Old 09-28-09, 09:28
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Just use a regular CREATE VIEW statement. There is nothing special about it. Of course, that's only the case for DB2 z/OS and if the table spaces reside in the same DB2 subsystem. If you have DB2 LUW, you'd need federation.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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