>데이터 베이스 >MySQL 튜토리얼 >Oracle中使用同义词

Oracle中使用同义词

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB원래의
2016-06-07 16:20:35929검색

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

   一、背景

  有两个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()。

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.