一、本地配置数据库实名配置远程连接
1 语法:
创建:CREATE DATABASE LINK 数据库链接名 CONNECT TO 用户名 IDENTIFIED BY 密码 USING '本地配置的数据的实例名';
删除:drop DATABASE LINK 数据库连接名;
例子:
创建:CREATE DATABASE LINK xiongminLink CONNECT TO epossdb IDENTIFIED BY eposseposs USING 'eposs';
删除:drop DATABASE LINK xiongminLink;
用远程连接查询数据库查询: select * from area@xiongminLink;
二、不依赖本地配置连接的远程连接查询
语法:
create database link 连接名
connect to 用户名 identified by 密码
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 数据库ip)(PORT = 端口))
)
(CONNECT_DATA =
(SERVICE_NAME = 数据库实例名)
)
)';
创建:
create database link linkTest
connect to epossdb identified by eposseposs
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.70.32.76)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)';