Personal tools
You are here: Home DB2 How To's How to use DB2 Federation
Navigation
Log in


Forgot your password?
 
Document Actions

How to use DB2 Federation

wrapper -> server -> user mapping -> nickname


Let's work with examples:


DB2 9.5
Environment Linux

db2 create database db1a
db2 create database db2a

 

db2 connect to db1a
db2 "create table schema1.tab1 (cod1 int)"
db2 "insert into schema1.tab1 values (1)"

 

db2 connect to db2a
db2 "create table schema2.tab2 (name1 char)"
db2 "insert into schema2.tab2 values ('a')"

 

 We want to perform a query on db2a while we are connected on db1a:

 

1 - Enabling Federated Database System Support :

db2 update dbm cfg using FEDERATED yes

 

2 - Recycle the instance

db2stop/db2start

 

 3 - Connect to db1a

db2 connect to db1a

4 - Create a wrapper on db21a

db2 create wrapper drda


5 - Create a server using the wrapper below to db21a adding the db2a database

db2 "create server sevdb2a type DB2/UDB version '9.5' wrapper drda authorization \"db2inst1\" PASSWORD \"db2inst1\" options( add dbname 'db2a')"

 the user and password for db2a database are: db2inst1

 
6 - Create user mapping for db2inst1 on server sevdb2a

db2 "CREATE USER MAPPING FOR schema2 SERVER SEVDB2A OPTIONS (REMOTE_AUTHID 'db2inst1', REMOTE_PASSWORD 'db2inst1')"

 

7 - Creating nickname for table schema2.tab2

db2 CREATE NICKNAME schema2.tab2 FOR SEVDB2A.schema2.tab2

 

 DONE !

 

Now you can use the table schema2.tab2 from db2a while you are connected on db21a, see some examples:

db2 connect to db21a
db2 "select * from schema2.tab2,schema1.tab1"

NAME1 COD1      
----- -----------
a               1

db2 "insert into schema2.tab2 values ('b')"

 

Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls