当前位置:才华屋 > 校园生活百科 > 语文 > Oracle中使用同义词的方法介绍
手机版

Oracle中使用同义词的方法介绍

来源:才华屋 阅读:2.83W 次

  一、背景

Oracle中使用同义词的方法介绍

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

 二、步骤

 ①登录Auser1对Auser2授权(若需要删除则加上)

grant ,select,u

pdate on table1 to Auser2;

grant ,select,on table2 to Auser2;

grant ,select,on table3 to Auser2;

grant execute on function1 to Auser2;

 ②登录Auser2建立同义词

create synonym table1 for e1;

create synonym table2 for e1;

create synonym table3 for e1;

create synonym function1 for tion1;

 ③登录Buser1查找db_link名(例如查出来的db_link名为mydblink1)

select username,db_link from user_db_links

  ④建立Buser1的.同义词

create synonym table1 for e1@mydblink1;

create synonym table2 for e2@mydblink1;

create synonym table3 for e3@mydblink1;

create synonym function1 for tion1@mydblink1;

  ⑤测试

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

  三、注意点

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

本文链接:https://www.caihuawu.com/xysh/yuwen/0zk30.html

Copyright © 2024. 才华屋 All right reserved. 黑ICP备20014756号-2

文字美图素材,版权属于原作者。部分文章内容由网友提供推送时因种种原因未能与原作者联系上,若涉及版权问题,敬请原作者联系我们,立即处理。