一、背景
有兩個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的同義詞
⑤測試
此時登入buser1通過select * from table1就可以通路table1了。
三、注意點
也可以建立procedure的同義詞,但是這樣執行的過程中不允許commit。如果要送出的話請在如jdbc中commit()。
四、一些資料