Re: Equivilant of Oracle's DB Links in DB2
Mark Townsend wrote:[color=blue][color=green]
> > Guess I will have the crack[/color]
>[color=green]
>> the doc.[/color]
>
>
> So from what I can see from the doc, the answer is something like this ?
>
> 1. Catalog the node
>
> For the example given, perhaps the following command
>
> CATALOG TCPIP NODE machine2 REMOTE 10.10.60.16 SERVER 50000
>
> 2. Catalog the remote database
>
> For the example given, perhaps the following command
>
> CATALOG DATABASE sample AS sample2 AT NODE machine2 AUTHENTICATION SERVER
>
> 3. Create the wrapper
>
> For the example given, on the OS's given, I don't believe DRDA is
> deployed by default, so the default DRDA wrapper cannot be used ?
> Instead, perhaps something like this ?
>
> CREATE WRAPPER sample_wrapper LIBRARY ’db2drda.dll’[/color]
DRDA is the only protocol used by DB2 UDB fro LUW . So it's always
there. Se emy other post for simplified notation.[color=blue]
>
> 4. Create the server definition and set the server options
>
> CREATE SERVER sample TYPE DB2/NT VERSION 8.1 WRAPPER sample_wrapper
> AUTHORIZATION "xxxx" PASSWORD "yyyyy" OPTIONS (DBNAME ’sample’)
>
> Did I use the right type (i.e is DB2/NT the right type for t a UDB
> database running on Win2K professional ?).[/color]
Yes. Syntax diagrams would start looking funny if IBM rode each renaming
bump of MS ;-)
Obviously I also don't have[color=blue]
> the right username/password to use either - but do I need one given that
> I defined the authentication model as "AUTHENTICA TION SERVER". Question
> - can you set this up so that each user of the connection needs to
> authenticate themselves with the target database at the time that they
> use the connection ?[/color]
From the docs it appears this is for whatever CREATE SERVER has to do
on the source system. So once the server is created that's in. No
worries for Joe user.
[color=blue]
> What other options should be specified here ? I note the PUSHDOWN option
> which is analogous to the remote_join hint in Oracle ? Is this pretty
> much mandatory to stop data from being shipped in the wrong direction
> when joined (or aggregated etc) ?[/color]
In general you use the default for the options.
DB2 has default settings for different versions of different products
which is why the version needs to be specified.
Tehse options can be very detailed. For example the wrapper would know
in which version of the target HASHJOIn was introduced, ...
If PSHDOWN is disabled that would take out teh main reason to use
Websphere II. So yes. It's pretty much mandatory and it is the default.
[color=blue]
> 5. Create the user mappings
>
> This one I didn't grok, but I think it's the answer to the
> authentication model question I answered above ? Why does it have to be
> defined ahead of time ?[/color]
Call it single-sign on.... If DB2 joins data from 5 different DBMS who
wants to type in all those passwords on every connect?
It is interesting to note that user-access to nicknames can never be
encapsulated. I.e. I cannot refer to a nickna in a procedure, grant
execute to public and allow the masses to read.
I used to hate this breakage with normal SQL rules, but in the federated
world this turns out to be a requirement....
[color=blue]
> 6. Test the connection to the DB2 server
>
> So here I note that I have to specify the server I want ahead of the
> query ? So to test I would do something like the following from the
> sample database on machine1 ? Hmm - both databases are called smaple -
> do I have a name collision problem ?
>
> SET PASSTHRU sample
> SELECT count(*) FROM some_remote_tab le
> SET PASSTHRU RESET[/color]
SET PASSTHRU (besides to do a sanity test) is used to specify
statements which are not supported by DB2.
A good example would be running a DDL script. I don't know off hand
whether DB2 supports remote DDL when the target is DB2, but I doubt it..
there are more important things to work on ....
DB2 supports aliasing of DB names so you can catalog the remote database
under a different name locally.
[color=blue]
> How do you do a join across both systems using this syntax ?[/color]
Wrong tool. Used for DDL (or if you don't have a nickname?), not for
general DML.
[color=blue]
> 7. Create the nicknames for tables and views
>
> OK - so to get around the SET PASSTHRU problem I need to create
> 'nicknames' for each remote table a la
> CREATE NICKNAME DB2SALES FOR SAMPLE.SALESDAT A.EUROPE
>
> Do I need to do this for each remote table ? Can I just specify the
> target in the SQL statement ? For instance
>
> SELECT count(*)
> from customer c,
> sample.salesdat a.europe s
> where c.status = "VALID" and c.id=s.cust_id[/color]
For each table you want to use. Yes.
There is a known requirement to support "3-part" table names.
Really nicknames and 3-part-names address two different issues.
When using a nickname DB2 catalogs all the good stuff about the table in
its local catalog. Including indexes, stats, etc, ...
This cuts down on the compile-time
3-part-table names address a different issues. That would be near random
access to tables, or table which have a volatile schema.
IMHO both approaches are valuable.
A note on the side. AFAIK, for IBM customers homogeneity of the data
sources is the exception. Websphere II is aimed at a heterogeneous
environment.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Mark Townsend wrote:[color=blue][color=green]
> > Guess I will have the crack[/color]
>[color=green]
>> the doc.[/color]
>
>
> So from what I can see from the doc, the answer is something like this ?
>
> 1. Catalog the node
>
> For the example given, perhaps the following command
>
> CATALOG TCPIP NODE machine2 REMOTE 10.10.60.16 SERVER 50000
>
> 2. Catalog the remote database
>
> For the example given, perhaps the following command
>
> CATALOG DATABASE sample AS sample2 AT NODE machine2 AUTHENTICATION SERVER
>
> 3. Create the wrapper
>
> For the example given, on the OS's given, I don't believe DRDA is
> deployed by default, so the default DRDA wrapper cannot be used ?
> Instead, perhaps something like this ?
>
> CREATE WRAPPER sample_wrapper LIBRARY ’db2drda.dll’[/color]
DRDA is the only protocol used by DB2 UDB fro LUW . So it's always
there. Se emy other post for simplified notation.[color=blue]
>
> 4. Create the server definition and set the server options
>
> CREATE SERVER sample TYPE DB2/NT VERSION 8.1 WRAPPER sample_wrapper
> AUTHORIZATION "xxxx" PASSWORD "yyyyy" OPTIONS (DBNAME ’sample’)
>
> Did I use the right type (i.e is DB2/NT the right type for t a UDB
> database running on Win2K professional ?).[/color]
Yes. Syntax diagrams would start looking funny if IBM rode each renaming
bump of MS ;-)
Obviously I also don't have[color=blue]
> the right username/password to use either - but do I need one given that
> I defined the authentication model as "AUTHENTICA TION SERVER". Question
> - can you set this up so that each user of the connection needs to
> authenticate themselves with the target database at the time that they
> use the connection ?[/color]
From the docs it appears this is for whatever CREATE SERVER has to do
on the source system. So once the server is created that's in. No
worries for Joe user.
[color=blue]
> What other options should be specified here ? I note the PUSHDOWN option
> which is analogous to the remote_join hint in Oracle ? Is this pretty
> much mandatory to stop data from being shipped in the wrong direction
> when joined (or aggregated etc) ?[/color]
In general you use the default for the options.
DB2 has default settings for different versions of different products
which is why the version needs to be specified.
Tehse options can be very detailed. For example the wrapper would know
in which version of the target HASHJOIn was introduced, ...
If PSHDOWN is disabled that would take out teh main reason to use
Websphere II. So yes. It's pretty much mandatory and it is the default.
[color=blue]
> 5. Create the user mappings
>
> This one I didn't grok, but I think it's the answer to the
> authentication model question I answered above ? Why does it have to be
> defined ahead of time ?[/color]
Call it single-sign on.... If DB2 joins data from 5 different DBMS who
wants to type in all those passwords on every connect?
It is interesting to note that user-access to nicknames can never be
encapsulated. I.e. I cannot refer to a nickna in a procedure, grant
execute to public and allow the masses to read.
I used to hate this breakage with normal SQL rules, but in the federated
world this turns out to be a requirement....
[color=blue]
> 6. Test the connection to the DB2 server
>
> So here I note that I have to specify the server I want ahead of the
> query ? So to test I would do something like the following from the
> sample database on machine1 ? Hmm - both databases are called smaple -
> do I have a name collision problem ?
>
> SET PASSTHRU sample
> SELECT count(*) FROM some_remote_tab le
> SET PASSTHRU RESET[/color]
SET PASSTHRU (besides to do a sanity test) is used to specify
statements which are not supported by DB2.
A good example would be running a DDL script. I don't know off hand
whether DB2 supports remote DDL when the target is DB2, but I doubt it..
there are more important things to work on ....
DB2 supports aliasing of DB names so you can catalog the remote database
under a different name locally.
[color=blue]
> How do you do a join across both systems using this syntax ?[/color]
Wrong tool. Used for DDL (or if you don't have a nickname?), not for
general DML.
[color=blue]
> 7. Create the nicknames for tables and views
>
> OK - so to get around the SET PASSTHRU problem I need to create
> 'nicknames' for each remote table a la
> CREATE NICKNAME DB2SALES FOR SAMPLE.SALESDAT A.EUROPE
>
> Do I need to do this for each remote table ? Can I just specify the
> target in the SQL statement ? For instance
>
> SELECT count(*)
> from customer c,
> sample.salesdat a.europe s
> where c.status = "VALID" and c.id=s.cust_id[/color]
For each table you want to use. Yes.
There is a known requirement to support "3-part" table names.
Really nicknames and 3-part-names address two different issues.
When using a nickname DB2 catalogs all the good stuff about the table in
its local catalog. Including indexes, stats, etc, ...
This cuts down on the compile-time
3-part-table names address a different issues. That would be near random
access to tables, or table which have a volatile schema.
IMHO both approaches are valuable.
A note on the side. AFAIK, for IBM customers homogeneity of the data
sources is the exception. Websphere II is aimed at a heterogeneous
environment.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Comment