时间:2021-07-11 08:43:15 | 栏目:Oracle | 点击:次
1.应用场景:
现有两个数据库,一个是nc650115,一个是nc56,现要通过dblink在nc650115连接nc56。
2.先在nc650115查看是否拥有创建dblink权限。在nc650115中执行
select * from user_sys_privs where privilege like upper('%DATABASE LINK%');
有权限显示如下
没有权限到sys里面授权
grant CREATE PUBLIC DATABASE LINK,DROP PUBLIC DATABASE LINK to nc650115;
3.在nc650115下创建dblink。
create public database link NC65DBLINK connect to nc56 identified by nc56 using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.17.254)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = orcl)))';
其中NC65DBLINK 为dblink名字,
connect to 需要连接的用户名 identified by 密码
HOST=需要连接数据库的ip
SERVICE_NAME=数据库实例
查看是否创建成功
select * from dba_db_links; select owner,object_name from dba_objects where object_type='DATABASE LINK';--查询时间久
4.操作:
查询nc56里面的数据
select * from crm_bd_building@NC65DBLINK
删除dblink
drop public database link NC65DBLINK