1、检查此用户是否有权限,图示为有权限
select * from user_sys_privs where privilege like upper('%DATABASE LINK%');
没有权限则去登录sys授权
grant CREATE PUBLIC DATABASE LINK,DROP PUBLIC DATABASE LINK to HOUSEYW0229;
2、创建DBLINK
create database link DBLINK_HOUSEYW0229
connect to HOUSEYW0229 identified by HOUSEYW0229
using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)';
DBLINK_HOUSEYW0229为 连接名,HOUSEYW0229 为用户名,HOUSEYW0229 为密码,127.0.0.1为连接的IP
3、查询是否创建成功
select * from dba_db_links;
select owner,object_name from dba_objects where object_type='DATABASE LINK';--查询时间久
4、使用DBLINK
select * from 表名@DBLINK_CF