Oracle使用同义词

一、背景
有两个sid:Asid,Bsid,在Asid下有两个用户Auser1,Auser2,在Bsid下有一个用户Buser1。其中Auser2和Buser1建立了dblink。现希望通过登录Buser1访问Auser1上的三张表table1,table2,table3信息和函数function1。

 

二、步骤
①登录Auser1对Auser2授权(若需要删除则加上delete)
grant insert,select,update on table1 to Auser2;
grant insert,select,update on table2 to Auser2;
grant insert,select,update on table3 to Auser2;
grant execute on function1 to Auser2;

②登录Auser2建立同义词
create synonym table1 for Auser1.table1;
create synonym table2 for Auser1.table1;
create synonym table3 for Auser1.table1;
create synonym function1 for Auser1.function1;

③登录Buser1查找db_link名(例如查出来的db_link名为mydblink1)
select username,db_link from user_db_links

④建立Buser1的同义词
create synonym table1 for Auser2.table1@mydblink1;
create synonym table2 for Auser2.table2@mydblink1;
create synonym table3 for Auser2.table3@mydblink1;
create synonym function1 for Auser2.function1@mydblink1;

⑤测试
此时登录Buser1通过select * from table1就可以访问table1了。

 

三、注意点

也可以建立procedure的同义词,但是这样执行的过程中不允许commit。如果要提交的话请在如JDBC中commit()。


四、一些资料
同义词介绍:http://blog.csdn.net/woshixuye/article/details/10209239

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值