database link远程链接数据库
时间:2021-07-01 10:21:17
帮助过:2人阅读
授权创建、删除dblink
GRANT CREATE [PUBLIC] DATABASE LINK,
DROP [PUBLIC] DATABASE LINK
TO canco;
--查看数据库GLOBAL_NAME(数据库名)
SELECT * FROM GLOBAL_NAME;
--查看有哪些dblink
select owner,
object_name from dba_objects
where object_type
=‘DATABASE LINK‘;
--删除dblink
DROP [public] DATABASE LINK nbcb;
--=======================================================================================================================================================
--创建dblink
create database link local218
connect to CANCO identified
by "
123"
using ‘(DESCRIPTION=(ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.218)(PORT = 1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=nbcb)))‘;
--创建同义词(隐藏链接的数据库)
create synonym nbcb_fa_monthout_t
for nbcb_fa_monthout_t
@local218;
--========================================================================================================================================================
--truncate 语句无法执行
--1、在目标数据库中创建过程
create or replace procedure Remote_ExecuteDDL(sqltext
in varchar2)
authid current_user as
begin
execute immediate sqltext;
end Remote_ExecuteDDL;
--2、传递需要执行的sql
Remote_ExecuteDDL
@nbcb(
‘truncate table canco.nbcb_fa_monthout_t‘);
--========================================================================================================================================================
database link远程链接数据库
标签: