1. 程式人生 > >Oracle 使用者許可權查詢

Oracle 使用者許可權查詢

--彙總:角色許可權、系統許可權、使用者許可權
select a.grantee,
       a.granted_role as "granted_role----table_name",
       to_char(replace(wm_concat(b.privilege), ',', ' || ')) privilege,
       'admin_option:' || a.admin_option as "option",
       'default_role:' || a.default_role as "default_role----hierarchy"
  from dba_role_privs a
  left join role_sys_privs b
    on a.granted_role = b.role
 where a.grantee = 'SBNI'
 group by a.grantee, a.granted_role, a.admin_option, a.default_role
union all
select grantee,
       '' granted_role,
       privilege,
       'admin_option:' || admin_option as "option",
       '' default_role
  from dba_sys_privs
 where grantee = 'SBNI'
union all
select grantee,
       owner || '.' || table_name as "table_name",
       --grantor,
       to_char(wm_concat(privilege)) as "privilege",
       'grant_option:' || grantable as "option",
       'hierarchy:' || hierarchy
  from dba_tab_privs
 where grantee = 'SBNI'
 group by grantee, owner, table_name, grantor, grantable, hierarchy;