Oracle賦予使用者查詢另乙個使用者所有表的許可權

2022-07-27 01:39:12 字數 1205 閱讀 5098

使用者:usera,userb

場景:使用者usera只有使用者userb指定表的查詢許可權。

解決方案:

1.給他一些許可權,包括連線許可權,因為他要建立同義詞,還需要給他同義詞

grant connect to usera;

grant create synonym to usera;

grant create session to usera;

2.因為需要把userb的所有表的查詢許可權給usera。所以需要所有表的grant select on table_name to usera語句,不可能一句一句去寫,因此用select 吧所有的grant語句查出來直接執行

select 'grant select on '||owner||'.'||object_name||' to usera;'

from dba_objects

where owner in ('userb')

and object_type='table';

把所有結果複製出來,在userb 下執行一遍

grant select on userb.table1 to usera;

grant select on userb.table2 to usera;

grant select on userb.table3 to usera;

3.需要給userb使用者下所有表建立同義詞,但是考慮到之前已經建立過一些表的同義詞,因此把所有建立同義詞的語句select出來在usera使用者下執行。

select 'create or replace synonym usera. ' || object_name|| ' for ' || owner || '.' || object_name|| ';'

from dba_objects

where owner in ('userb')

and object_type='table';

把所有結果複製出來登入usera使用者執行

create or replace synonym  usera. t_kdxf_account for userb.table1 ;

create or replace synonym  usera. t_kdxf_account for userb.table2 ;

create or replace synonym  usera. t_kdxf_account for userb.table3 ;

C Oracle賦予另乙個使用者查詢許可權,建立同義詞

使用者 usera,userb 場景 使用者usera只有使用者userb指定表的查詢許可權。解決方案 1.給他一些許可權,包括連線許可權,因為他要建立同義詞,還需要給他同義詞 grant connect to usera grant create synonym to usera grant cr...

Oracle乙個使用者查詢另乙個使用者的表資料

1 兩個使用者是在不同的庫,需要建立dblink 2 屬於同乙個庫的不同使用者 1 方法一 使用 使用者名稱.的方式訪問 例如 要從user1賬號訪問user2中的表table2 a.需要在user2中將table2 grant給user1,user1才有許可權訪問,訪問的時候用select fro...

oracle 記錄被另乙個使用者鎖住

今天在oracle資料中刪除資料時提示 記錄被另乙個使用者鎖住 解決方法 1 檢視資料庫鎖,診斷鎖的 及型別 select object id,session id,locked mode from v locked object 或者用以下命令 select b.owner,b.object na...