角色管理相关的数据字典

一、与角色有关的数据字典

    * MAX_ENABLED_ROLES

    * OS_ROLES

    * REMOTE_OS_ROLES

    * DBA_APPLICATION_ROLES

    * DBA_CONNECT_ROLE_GRANTEES

    * DBA_ROLE_PRIVS

    * DBA_ROLES

    * ROLE_ROLE_PRIVS

    * ROLE_SYS_PRIVS

    * ROLE_TAB_PRIVS

    * SESSION_ROLES

    * USER_ROLE_PRIVS

二、一些常见问题的解答

1、用户想查看自己都拥有哪些角色?

USER_ROLE_PRIVS

USER_ROLE_PRIVS describes the roles granted to the current user.

select granted_role from user_role_privs; 

或者:

select * from user_role_privs ;(因为这个静态数据字典视图,只有5列,都select出来也不多)。

2、用户想查看自己当前激活的角色都有哪些?

SESSION_ROLES

SESSION_ROLES lists the roles that are currently enabled to the user.

select role from session_roles;

或者:

select * from session_roles; 因为这个数据字典视图,只有一列:roles

3、用户想查看自己拥有的每个角色里,都有哪些系统、对象权限、角色?

1)、系统权限:

select * from role_sys_privs;

ROLE_SYS_PRIVS

ROLE_SYS_PRIVS describes system privileges granted to roles. Information is provided only about roles to which the user has access

2)、对象权限:

select * from role_tab_privs;

ROLE_TAB_PRIVS

ROLE_TAB_PRIVS describes table privileges granted to roles. Information is provided only about roles to which the user has access.

3)、角色里都包含哪些角色:

ROLE_ROLE_PRIVS

ROLE_ROLE_PRIVS describes the roles granted to other roles. Information is provided only about roles to which the user has access.

select * from role_role_privs;

4、用户想知道自己拥有的这些角色,在激活时,都有哪些需要输入密码,哪些不需要?

这个不知道用户能不能查看,DBA可以通过查询:dba_roles 查看。

5、用户想查看自己都拥有哪些系统权限?

SQL> select * from user_sys_privs; 

USER_SYS_PRIVS

USER_SYS_PRIVS lists system privileges granted to the current user.

注:假如先将某个系统权限赋给了某个角色,再将这个角色赋给了某个用户,那么此时,用户执行:select * from user_sys_privs; 时,是看不到那个系统权限的,但是是可以执行和那个系统权限相关的操作的。

如果DBA直接执行的:grant create table to user1

的话,用户执行: select * from user_sys_privs 时,是能看的到相应的系统权限:create table的。

对于下面的对象权限,也是这种情况。另外,某个角色中包含某个系统权限或者对象权限,然后这个角色被赋予给了某个用户。此时,即使dba 执行:

revoke   系统权限或者对象权限 from username;  

也是收不回来的,只能通过收回角色收回来。                                                                   

6、用户想查看自己都拥有哪些对象权限?

SQL> select * from user_tab_privs;

USER_TAB_PRIVS

USER_TAB_PRIVS describes the object grants for which the current user is the object owner, grantor, or grantee.

注意上面的那种情况。

7dba想查看当前系统上都有哪些角色?

select * from dba_roles

DBA_ROLES

DBA_ROLES lists all roles that exist in the database.

注:通过查询这个数据字典视图,也可以查询某个角色,在启用时,是否需要输入密码。

Column              Description

ROLE                  Role name

PASSWORD_REQUIRED    Indicates if the role requires a password to be enabled

8dba想查看某个角色都包含哪些内容:系统权限、对象权限、角色?

目前(201055日),我还不知道:查询某个角色里都包含哪些系统权限、对象权限、角色时,DBA可以查询不同于普通用户的数据字典视图,我在实验时的实验现象是:

普通用户和DBA都可以查询:role_role_privsrole_sys_privsrole_tab_privs等视图,但是:

DBA用户看到的行数要大于普通用户。我不知道:是不是两者虽然看到的都是同一个视图,但是oracle会根据用户的身份,选择显示给用户的行数;还是普通用户和DBA看到的压根就是两个不同的数据字典视图,只是表面上看名称相同而已?

1)、系统权限:

select * from role_sys_privs;

ROLE_SYS_PRIVS

ROLE_SYS_PRIVS describes system privileges granted to roles. Information is provided only about roles to which the user has access

2)、对象权限:

select * from role_tab_privs;

ROLE_TAB_PRIVS

ROLE_TAB_PRIVS describes table privileges granted to roles. Information is provided only about roles to which the user has access.

3)、角色里都包含哪些角色:

ROLE_ROLE_PRIVS

ROLE_ROLE_PRIVS describes the roles granted to other roles. Information is provided only about roles to which the user has access.

select * from role_role_privs;

另外,对于DBA来讲,还可以通过:dba_role_privs 权限, 9类似。

9dba想查看某个用户都被赋予了哪些角色?

select * from dba_role_privs where grantee='USER1';

DBA_ROLE_PRIVS

DBA_ROLE_PRIVS describes the roles granted to all users and roles in the database

DBA_ROLE_PRIVS 视图,包含系统中都有哪些用户被授予了哪些角色。

注:不同于:包含所有的角色,包含所有的用户信息。比如:

如果:系统中确实存在某个用户,但是这个用户只有系统权限,没有角色,那么上面是不会有的;

如果:DBA新创建了一个角色,但是这个角色,尚未被赋给某个用户,那么此时dba_role_privs视图里只有一行信息,是:sys用户被赋予了这个角色,貌似:默认sys用户创建完一个角色后,这个角色就自动被赋给了自己。这个应该算是特殊情况。

10dba想查看某个角色都被赋给了哪些用户?

select granted_role as "Role name",grantee as "granted to user" from dba_role_privs where granted_role='角色名';

11dba想查看某个用户都被赋给了哪些系统权限?

select * from dba_sys_privs where grantee=’用户名

DBA_SYS_PRIVS

DBA_SYS_PRIVS describes system privileges granted to users and roles. This view does not display the USERNAME column.

可以通过查询:dba_sys_privs 数据字典视图,查看某个用户或者某个角色被授予了什么权限。

另外,通过这个视图,也可以查询某个角色被授予了哪些系统权限,也能达到:

38中(1)的目的。

12dba想查看某个用户都拥有哪些系统对象权限?

select * from dba_tab_privs where grantee=’用户名

DBA_TAB_PRIVS

DBA_TAB_PRIVS describes all object grants in the database.

可以通过查询:dba_tab_privs 数据字典视图,查看某个用户被授予了什么对象权限。

另外,通过这个视图,也可以查询某个角色被授予了哪些对象权限,也能达到:

38中(2)的目的。

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23230551/viewspace-661979/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/23230551/viewspace-661979/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值