Search code examples
databasedb2federated

Define Federated Object on DB2


I'm currently learning the basics of DB2 in school. Right now we are working on Federated Data Sources.

I've been trying to solve this one exercise, but I'm stuck:

In database DB001, table SH1.TB001 is to be included as a Federated Data Source. The Federated Object should have the name NTAB (the nickname) and be defined in schema SH1.

I'm searching a solution on the IBM Knowledge Center, but I couldn't find anything.

I have to work essentially directly on my CentOS server, with the terminal. The only "external" programm I can use is DBeaver.

Since I have no experience with this, any type of help or advice is appreciated!


Solution

  • there is two way to access remote data in DB2:

    1.create a nickname, and use it as local table:

    Create NICNAME SCHMx.NICKNAMEx for <remote server>.<remote schema>.<remote table>
    

    then you can use SCHMx.NICKNAMEx as a local table:

    select count(*) from SCHMx.NICKNAMEx
    

    2.Use Federated three-part names:

    select count(*) from <remote server>.<remote schema>.<remote table>
    

    you can find the documentation her: https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.data.fluidquery.doc/topics/iiyfq3pnintro.html