一、背景 有兩個sid:Asid,Bsid,在Asid下有兩個用戶Auser1,Auser2,在Bsid下有一個用戶Buser1。其中Auser2和Buser1建立了dblink?,F(xiàn)希望通過登錄Buser1訪問Auser1上的三張表table1,table2,table3信息和函數(shù)function1。 二、步驟 ①登錄Auser1對Auser2授
一、背景
有兩個sid:Asid,Bsid,在Asid下有兩個用戶Auser1,Auser2,在Bsid下有一個用戶Buser1。其中Auser2和Buser1建立了dblink?,F(xiàn)希望通過登錄Buser1訪問Auser1上的三張表table1,table2,,table3信息和函數(shù)function1。
二、步驟
?、俚卿汚user1對Auser2授權(quán)(若需要刪除則加上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;
?、诘卿汚user2建立同義詞
create synonym table1 for Auser1.table1;
create synonym table2 for Auser1.table1;
create synonym table3 for Auser1.table1;
create synonym function1 for Auser1.function1;
?、鄣卿汢user1查找db_link名(例如查出來的db_link名為mydblink1)
select username,db_link from user_db_links
?、芙user1的同義詞
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;
?、轀y試
此時登錄Buser1通過select * from table1就可以訪問table1了。
三、注意點
也可以建立procedure的同義詞,但是這樣執(zhí)行的過程中不允許commit。如果要提交的話請在如JDBC中commit()。
Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號-2
違法及侵權(quán)請聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)