2014-06-23 48 views

回答

4

您可以使用下面的查詢。它會顯示所有當前會話的用戶可以訪問的表,

select * from user_tables; 

要查看所有的表,

select * from all_tables; 

名單誰被分配一個特定的角色

所有用戶
-- Change 'DBA' to the required role 
select * from dba_role_privs where granted_role = 'DBA' 

列出給予用戶的所有角色

-- Change '[email protected] to the required user 
select * from dba_role_privs where grantee = 'PHIL'; 

列表提供給用戶的所有權限

select 
    lpad(' ', 2*level) || granted_role "User, his roles and privileges" 
from 
    (
    /* THE USERS */ 
    select 
     null  grantee, 
     username granted_role 
    from 
     dba_users 
    where 
     username like upper('%&enter_username%') 
    /* THE ROLES TO ROLES RELATIONS */ 
    union 
    select 
     grantee, 
     granted_role 
    from 
     dba_role_privs 
    /* THE ROLES TO PRIVILEGE RELATIONS */ 
    union 
    select 
     grantee, 
     privilege 
    from 
     dba_sys_privs 
) 
start with grantee is null 
connect by grantee = prior granted_role; 

注:從http://www.adp-gmbh.ch/ora/misc/recursively_list_privilege.html

一覽表中的表有一定的作用給予SELECT訪問多久?

-- Change 'DBA' to the required role. 
select * from role_tab_privs where role='DBA' and privilege = 'SELECT'; 

列出所有表的用戶可以從中選擇?

--Change 'PHIL' to the required user 
select * from dba_tab_privs where GRANTEE ='PHIL' and privilege = 'SELECT'; 

名單誰可以在特定表選擇所有用戶(無論是通過被賦予相應的作用或通過直接補助(即授予上atable選擇喬))?此查詢的結果還應顯示用戶具有此訪問權的角色或者是否爲直接授予。

-- Change 'TABLENAME' below 
select Grantee,'Granted Through Role' as Grant_Type, role, table_name 
from role_tab_privs rtp, dba_role_privs drp 
where rtp.role = drp.granted_role 
and table_name = 'TABLENAME' 
union 
select Grantee,'Direct Grant' as Grant_type, null as role, table_name 
from dba_tab_privs 
where table_name = 'TABLENAME' ; 

Reference

+0

嗨Nishanthi Grashia, 使用上面的這個命令,我找不到「UserName」列來過濾我的指定用戶。 我需要輸入更多參數嗎? –

+0

是啊嗨,希望我的回答可以幫助你! –

+0

@JackVo:你在說什麼查詢?你想要的用戶名是什麼? –

0

http://docs.oracle.com/cd/B10501_01/server.920/a96521/privs.htm#15665

檢查USER_SYS_PRIVS,USER_TAB_PRIVS,USER_ROLE_PRIVS表。

也是用這個是有幫助的: -

select * from USER_ROLE_PRIVS where USERNAME='SAMPLE'; 
select * from USER_TAB_PRIVS where Grantee = 'SAMPLE'; 
select * from USER_SYS_PRIVS where USERNAME = 'SAMPLE'; 

貫徹「用戶」而不是樣品來獲得當前登錄的用戶信息。希望這可以幫助!

相關問題