oracle – 列出可以访问某些表的用户

我确信以前曾经问过这个问题,但我似乎无法找到以下相关细节.

是否有某种预先构建的表可以执行以下操作(我使用了dba_tab_privs,但它是有限的,不能满足我的所有需求),如果没有,是否有人有一些查询来回答以下问题?

>列出已分配特定角色的所有用户?
>列出给用户的所有角色?
>列出给予用户的所有权限?
>列出某个角色赋予SELECT访问权限的哪些表?
>列出用户可以从中选择的所有表格?
>列出可以在特定表上进行SELECT的所有用户(通过给予相关角色或通过直接授权(即授予joe的授权选择))?此查询的结果还应显示用户具有此访问权限的角色,或者是否是直接授权.

列出已分配特定角色的所有用户
-- Change 'DBA' to the required role
select * from dba_role_privs where granted_role = 'DBA'

列出给予用户的所有角色

-- Change 'PHIL@ 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';

列出可以在特定表上进行SELECT的所有用户(通过给予相关角色或通过直接授权(即授予joe的授权选择))?此查询的结果还应显示用户具有此访问权限的角色,或者是否是直接授权.

-- 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' ;

相关文章

文章浏览阅读773次,点赞6次,收藏9次。【代码】c# json字符...
文章浏览阅读8.7k次,点赞2次,收藏17次。此现象一般定位到远...
文章浏览阅读2.8k次。mysql脚本转化为oracle脚本_mysql建表语...
文章浏览阅读2.2k次。cx_Oracle报错:cx_Oracle DatabaseErr...
文章浏览阅读1.1k次,点赞38次,收藏35次。本文深入探讨了Or...
文章浏览阅读1.5k次。默认自动收集统计信息的时间为晚上10点...