我要投稿 投诉建议

Oracle中使用同义词介绍

时间:2021-04-11 09:31:21 同义词 我要投稿

Oracle中使用同义词介绍

  一、背景

Oracle中使用同义词介绍

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

  二、步骤

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

  grant ,select,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 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()。

【Oracle中使用同义词介绍】相关文章:

使用的同义词04-15

写作中同义词列举05-22

考虑的同义词介绍01-14

新鲜的同义词介绍05-03

享受的同义词介绍01-14

生长同义词介绍11-18

外强中干的同义词08-09

管中规豹同义词03-28

幸福的同义词介绍及造句09-11