0

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!

F Rowe
  • 2,042
  • 1
  • 11
  • 12
serlag8622
  • 25
  • 1
  • 1
  • 7
  • 1
    Look at the `CREATE NICKNAME` statement description in the Knowledge Center. – Mark Barinstein Jan 02 '21 at 16:11
  • Hi Mark. Thanks for your help. I found a good example, but I'm still quite confused. This is the example: Create a nickname for a view, DEPARTMENT, that is in a schema called HEDGES. This view is stored in a Db2 for z/OS data source called OS390A. CREATE NICKNAME DEPT FOR OS390A.HEDGES.DEPARTMENT I know the schema and the table, but I don't know if there's already a data source. Are there any way to find it out? – serlag8622 Jan 02 '21 at 17:25
  • 1
    Look at the [SYSCAT.SERVERS catalog view](https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.sql.ref.doc/doc/r0002187.html) to get registered data sources. It would be useful to study architecture of [Federation](https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.data.fluidquery.doc/doc/t0070493.html) as well. – Mark Barinstein Jan 03 '21 at 09:14

1 Answers1

2

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

mshabou
  • 524
  • 3
  • 6