創建nickname 整理版

I will connect another database on the same host.

 

1) Enable federation

 

db2 update dbm cfg using federated yes

db2stop;db2start <----------------------------restart db2

 

2) Set communication type and port

 

db2 update dbm cfg using svcename <port num> <--- choose a port number, for example 55000

db2set db2comm=tcpip      <------------------------ using tcpip protocol

db2stop;db2start

 

3) catalog node and test it

 

db2 "catalog tcpip node <nodename> remote <hostname or ip> server <port num>"

db2 "catalog database <remote db name> as <aliasname> at node <nodename> authentication dcs"

 

<nodename> is arbitrary;

<remote db name> is the database you want to connect to ;

<aliasname> is the name you can connect to locally.

 

db2 connect to <aliasname> user <usrid> using <password>

 

 

If I connect to the local db2, <usrid> and <password> is the same as the system user.

This the connection is established, the upper setting works.

 

db2 connect reset

 

4) create local database and create wrapper, server and mapping

 

db2 create database localdb

db2 connect to localdb

db2 "create wrapper <wrappername>"

 

db2 "create server <remotename> type db2/udb version '9.7' wrapper /"<wrappername>/" authid /"<usrid>/" password /"<password>/" options (add dbname '<dbname>', password 'Y', pushdown 'Y')"

 

db2 "create user mapping for /"<usrid>/" server <remotename> options (add remote_authid 'usrid', add remote_password '<password>')"

 

If we want to drop mapping, use

 

db2 "drop user mapping for /"<usrid>/" server <remotename>"

 

5) create nickname

 

db2 "create nickname <schema>.<nickname> for <servername>.<schema>.<tablename>"

 

db2 "select * from <schema>.<nickname>"

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章