时间:2021-07-01 10:21:17 帮助过:20人阅读
[CONNECT TO [user][current_user] IDENTIFIED BY password]
[AUTHENTICATED BY user IDENTIFIED BY password]
[USING ‘connect_string‘]
实例:
create database link a_to_b
connect to user_b_username identified by user_b_password
using ‘数据库b地址:端口/服务名‘
这个比较简单的一种方式
其中:
a_to_b是连接名
user_b_username 是要接连的目标的数据库用户
user_b_password是要连接的目标数据库密码
数据库集群的话也可以这么写
create public database link dblinkname connect to username identified by password
using ‘(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = database_ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME =servicename)
)
)‘;
访问相关信息
select * from table_b@a_to_b
查询数据库连接:
select * from dba_db_links
删除连接:
drop database link a_to_b
另外 此种方式默认创建的是本用户可用,如果要通用的可以创建public database link
Oracle Database Link 的创建和使用小见
标签:prot ble link ddr 数据库连接 通用 using dba tab