创建nickname 整理版

本文详细介绍如何在DB2数据库中设置联邦连接,包括启用联邦、设置通信类型及端口、目录节点配置与测试、创建本地数据库及相关组件、创建别名等步骤。通过这些步骤可以实现跨数据库查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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>"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值