ORACLE 11g使用者權限管理查詢

來源:互聯網
上載者:User

標籤:角色   style   roo   tab   查詢   ted   ant   and   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使用者權限管理查詢

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.