一、与角色有关的数据字典
* 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.
注意上面的那种情况。
7、dba想查看当前系统上都有哪些角色?
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
8、dba想查看某个角色都包含哪些内容:系统权限、对象权限、角色?
目前(2010年5月5日),我还不知道:查询某个角色里都包含哪些系统权限、对象权限、角色时,DBA可以查询不同于普通用户的数据字典视图,我在实验时的实验现象是:
普通用户和DBA都可以查询:role_role_privs、role_sys_privs、role_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类似。
9、dba想查看某个用户都被赋予了哪些角色?
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用户创建完一个角色后,这个角色就自动被赋给了自己。这个应该算是特殊情况。
10、dba想查看某个角色都被赋给了哪些用户?
selectgranted_roleas "Role name",granteeas "granted to user" from dba_role_privs where granted_role='角色名';
11、dba想查看某个用户都被赋给了哪些系统权限?
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数据字典视图,查看某个用户或者某个角色被授予了什么权限。
另外,通过这个视图,也可以查询某个角色被授予了哪些系统权限,也能达到:
3、8中(1)的目的。
<!--[if !vml]--><!--[endif]-->
12、dba想查看某个用户都拥有哪些系统对象权限?
select * from dba_tab_privs where grantee=’用户名’
DBA_TAB_PRIVS
DBA_TAB_PRIVS describes all object grants in the database.
可以通过查询:dba_tab_privs数据字典视图,查看某个用户被授予了什么对象权限。
另外,通过这个视图,也可以查询某个角色被授予了哪些对象权限,也能达到:
3、8中(2)的目的。
<!--[if !vml]-->
* 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.
注意上面的那种情况。
7、dba想查看当前系统上都有哪些角色?
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
8、dba想查看某个角色都包含哪些内容:系统权限、对象权限、角色?
目前(2010年5月5日),我还不知道:查询某个角色里都包含哪些系统权限、对象权限、角色时,DBA可以查询不同于普通用户的数据字典视图,我在实验时的实验现象是:
普通用户和DBA都可以查询:role_role_privs、role_sys_privs、role_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类似。
9、dba想查看某个用户都被赋予了哪些角色?
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用户创建完一个角色后,这个角色就自动被赋给了自己。这个应该算是特殊情况。
10、dba想查看某个角色都被赋给了哪些用户?
selectgranted_roleas "Role name",granteeas "granted to user" from dba_role_privs where granted_role='角色名';
11、dba想查看某个用户都被赋给了哪些系统权限?
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数据字典视图,查看某个用户或者某个角色被授予了什么权限。
另外,通过这个视图,也可以查询某个角色被授予了哪些系统权限,也能达到:
3、8中(1)的目的。
<!--[if !vml]--><!--[endif]-->
12、dba想查看某个用户都拥有哪些系统对象权限?
select * from dba_tab_privs where grantee=’用户名’
DBA_TAB_PRIVS
DBA_TAB_PRIVS describes all object grants in the database.
可以通过查询:dba_tab_privs数据字典视图,查看某个用户被授予了什么对象权限。
另外,通过这个视图,也可以查询某个角色被授予了哪些对象权限,也能达到:
3、8中(2)的目的。
<!--[if !vml]-->