赞
踩
-
--查看是否有数据库dblink的权限
select * from user_sys_privs where privilege like upper('%DATABASE LINK%');
--没有就授权
grant CREATE PUBLIC DATABASE LINK,DROP PUBLIC DATABASE LINK to TEST;
--dblink创建
create public database link hsotbTestDBLINK
-- (hsotbTestDBLINK为dblink名字,hsotb_test为数据库用户名,vtradex为用户名密码,引号内容为远程数据库下tnsnames.ora文件内容)
connect to test identified by vtradex
using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 10.xx.46.xx)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = hxwlwzYSP)))';
--查看是否创建成功
select * from dba_db_links;
select owner,object_name from dba_objects where object_type='DATABASE LINK';--查询时间久
--查询SOTBTESTDBLINK里面的orders表里的数据
SELECT * FROM orders@HSOTBTESTDBLINK;
--删除dblink
drop public database link HSOTBTESTDBLINK
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。