微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐