日期:2014-05-16 浏览次数:20504 次
简单的介绍oracle的dblink和synonym的创建、删除及使用
-- 授权给scott
grant create any database link to scott
grant create public database link to scott
grant drop database link to scott
grant drop public database link to scott
-- 创建公共的dblink
create public database link test_public
connect to scott identified by scott
using 'ORCL';
--配置的字符串(注意host(ip) 和 orcl(实例名))
create public database link test_public
connect to scott identified by scott
?using '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCL)
)
)';
-- 创建私有的dblink
create database link test
connect to scott identified by scott
using 'ORCL';
-- 删除公共的dblink
drop public database link test_public
-- 删除私有的dblink
drop database link test
-- 授权给scott
grant create any synonym to scott
grant create public synonym to scott
grant drop synonym to scott
grant drop public synonym to scott
-- 创建公共的同义词
create public synonym test_public
for emp;
create public synonym test_public
for emp@test_public;
-- 创建私有的同义词
create synonym test
for emp;
create synonym test
for emp@test_public;
-- 删除公共的synonym
drop public synonym test_public
-- 删除私有的synonym
drop synonym test
-- 使用(dblink,synonym)
select * from emp@test_public;
select * from emp@test;
select * from test_public;
select * from test;
参考网址:http://dev.yesky.com/137/7513137.shtml