当前位置: 代码网 > it编程>数据库>Oracle > Oracle查询用户拥有所有系统权限的方法

Oracle查询用户拥有所有系统权限的方法

2024年12月28日 Oracle 我要评论
oracle查询用户拥有所有系统权限sql> desc dba_sys_privs; 查询对象拥有的系统权限 name

oracle查询用户拥有所有系统权限

sql> desc dba_sys_privs;   查询对象拥有的系统权限
 name                                     null?    type
 ---------------------------------------- -------- ---------------------------
 grantee                                  not null varchar2(30)
 privilege                                not null varchar2(40)
 admin_option                                      varchar2(3)
sql> select * from dba_sys_privs where grantee='hr';
grantee                        privilege                                adm
------------------------------ ---------------------------------------- ---
hr                             unlimited tablespace                     no
hr                             create session                           no
hr                             create table                             no
sql> desc dba_role_privs;
 name                                     null?    type
 ---------------------------------------- -------- ---------------------------
 username                                          varchar2(30)
 granted_role                                      varchar2(30)
 admin_option                                      varchar2(3)
 default_role                                      varchar2(3)
 os_granted                                        varchar2(3)
sql> select * from dba_role_privs where grantee='hr';对象拥有的角色
grantee                        granted_role                   adm def
------------------------------ ------------------------------ --- ---
hr                             resource                       no  yes
sql> select * from role_sys_privs where role='resource';  通过角色查找权限
role                           privilege                                adm
------------------------------ ---------------------------------------- ---
resource                       create trigger                           no
resource                       create sequence                          no
resource                       create type                              no
resource                       create procedure                         no
resource                       create cluster                           no
resource                       create operator                          no
resource                       create indextype                         no
resource                       create table                             no
sql>  select a.granted_role,b.privilege,c.privilege
     from dba_role_privs a,role_sys_privs b ,dba_sys_privs c
   where a.granted_role=b.role and a.grantee=c.grantee and a.grantee='hr
resource        create sequence      unlimited tablespace
resource        create indextype     create session
--看起来很美好,但是这是等值才返回结果,1=1=1   3*8=24t条记录
select a.granted_role,b.privilege,c.privilege from dba_role_privs
a join role_sys_privs b on a.granted_role=b.role join dba_sys_privs
c on a.grantee=c.grantee and a.grantee='hr';  --一样无法达到效果;
--a  通过用户查找拥有的角色
select * from dba_role_privs  grantee granted_role
-b  通过角色查找拥有的权限
select * from role_sys_privs    1-2 role  granted_role
-c 通过用户查找拥有的系统权限
select * from dba_sys_privs  1-3 grantee 
--思路1+2=2 => 2+3=总
select * from (select a.grantee,b.privilege from
 dba_role_privs a join role_sys_privs b on a.granted_role=b.role
  union
   select c.grantee,c.privilege from dba_sys_privs c)
    where grantee='hr';
--于上一样--where条件执行速度更快
select a.grantee,b.privilege from
 dba_role_privs a join role_sys_privs b 
    on a.granted_role=b.role where grantee='hr'
  union 
   select c.grantee,c.privilege from dba_sys_privs c where grantee='hr';
意义:有些权限不是通过角色单独授予、或者单独授予权限:通过集合更好查找用户有啥权限
 ****补充:
--什么是对象权限,设计到具体的针对某一个对象的权限;
grant select on scott.dept to hr;
查询会有具体对象的权限;
select * from dba_tab_privs where grantee='hr';
hr         sys        yang       sys        write      no  no
hr         sys        yang       sys        read       no  no
hr         sys        dbms_stats sys        execute    no  no
hr         scott      dept       scott      select     no  no
回收: revoke execute on sys.dbms_stats from hr;

到此这篇关于oracle查询用户拥有所有系统权限的文章就介绍到这了,更多相关oracle查询用户拥有权限内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

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

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com