create database link DATABASE_LINK_TEST--数据库别名
connect to DB_TEST identified by DB_TEST--分别对应用户名和密码
using '127.0.0.1:1521/ORCL';--域名:端口号/数据库实例
create database link 随便起个名字
connect to 用户名 identified by 密码
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 域名)(PORT = 端口号))
(CONNECT_DATA =
(SERVICE_NAME = 数据库实例名称)
)';
-- Create database link
create database link DATABASE_LINK_TEST --自定义要连接的数据库名称
connect to username identified by password --用户名和密码
using '(DESCRIPTION = --数据库连接:域名,端口号,数据库实例
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
第二步:调用方式
B库表名@连接的B数据库的别名
select * from BASE_TEST@DATABASE_LINK_TEST