ORACLE 11g用户权限管理查询

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ORACLE 11g用户权限管理查询相关的知识,希望对你有一定的参考价值。

1、查看数据库里所有用户各自拥有的角色:
  select * from (select distinct connect_by_root grantee username,granted_role
        from dba_role_privs
        connect by prior granted_role =grantee ) a
  where exists (select 1 from dba_users b where b.username=a.username)
  order by 1,2;


2、查看数据库所有用户的系统权限:
  select d.username,d.privilege from
        (select a.username,b.privilege from
            (select distinct connect_by_root grantee username,granted_role
                from dba_role_privs
                connect by prior granted_role =grantee) a,
            (select grantee,privilege from dba_sys_privs) b
        where a.granted_role=b.grantee
        union
        select grantee,privilege from dba_sys_privs) d
        where exists((select 1 from dba_users c where d.username=c.username)
        )
  order by 1,2;



3、查看数据库所有用户的表权限
  select d.username,d.privilege,d.owner,d.table_name from
          (select a.username,b.privilege,b.owner,b.table_name from
                (select distinct connect_by_root grantee username,granted_role
                    from dba_role_privs
                  connect by prior granted_role =grantee) a,
                (select grantee,owner,table_name,privilege from dba_tab_privs) b
          where a.granted_role=b.grantee
          union
          select grantee,privilege,owner,table_name from dba_tab_privs) d
            where exists((select 1 from dba_users c where d.username=c.username)
          )
     order by 1,2;



4、如何查看拥有DBA角色的用户?
常规做法,一般是直接查询DBA_ROLE_PRIVS视图。查询语句如下:
  select grantee,granted_role from dba_role_privs where granted_role=’DBA’;    //这会漏掉用户

正确的查询应按如下语句查询:
select * from (select distinct connect_by_root grantee username,granted_role
      from dba_role_privs
      connect by prior granted_role =grantee ) a
where a.granted_role=’DBA’;


5、查看拥有SELECT ANY TABLE权限的用户
对于授予角色的,看看都谁有查询所有表的权限
  select distinct rp.grantee  from dba_role_privs rp ,dba_sys_privs sp
  where rp.granted_role = sp.grantee
   and sp.privilege like ‘SELECT ANY TABLE%‘
























































以上是关于ORACLE 11g用户权限管理查询的主要内容,如果未能解决你的问题,请参考以下文章

(总结)Oracle 11g用户表空间权限常用管理命令

Oracle11g全新讲解之用户权限管理

oracle11g系统用户

Oracle11g温习-第十七章:权限管理

Oracle 11g 创建表空间权限不足试过了好多方法还是没用

oracle 11g 如何建立表空间及用户,分配用户权限等