11gOCP 1z0-052 :2013-09-12 SELECT_CATALOG_ROLE角色
11gOCP 1z0-052 :2013-09-12 SELECT_CATALOG_ROLE角色
正确答案:A
启用角色
默认方式下,如果为用户授予了角色,则将启用角色。这意味着,在建立了连接用户账户的会话的时,将激活授予此角色的所有权限和其它角色。通过将角色设置为非默认来修改此行为。下面的查询接着前面给出的示例。显示已为SL_REP授予了什么角色。
1、创建用户SL_REP
[html]
gyj@OCM> create user SL_REP identified by SL_REP default tablespace users;
ser created.
2、授权
[html]
gyj@OCM> grant resource,connect to SL_REP;
Grant succeeded.
gyj@OCM> grant SELECT_CATALOG_ROLE to SL_REP;
Grant succeeded.
3、查询用户SL_REP所有角色
[html]
gyj@OCM> select GRANTED_ROLE ,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where grantee='SL_REP';
GRANTED_ROLE ADM DEF
------------------------------ --- ---
SELECT_CATALOG_ROLE NO YES
RESOURCE NO YES
CONNECT NO YES
已为SL_REP授予了RESOURCE/CONNECT/SELECT_CATALOG_ROLE角色。他不拥有这些角色的管理权限(因此不能将其传递给其他人),但每个角色都是默认的角色,每当连接时,将拥有这些角色。
我给这些角色设置为非默认的用如下命令:
[html]
gyj@OCM> alter user SL_REP default role none;
User altered.
gyj@OCM> select GRANTED_ROLE ,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where grantee='SL_REP';
GRANTED_ROLE ADM DEF
------------------------------ --- ---
SELECT_CATALOG_ROLE NO NO
RESOURCE NO NO
CONNECT NO NO
gyj@OCM> conn SL_REP/SL_REP
ERROR:
ORA-01045: user SL_REP lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
果然非默认的是不能用的,需要激……
[html]
gyj@OCM> alter user SL_REP default role connect,resource;
User altered.
gyj@OCM> select GRANTED_ROLE ,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where grantee='SL_REP';
GRANTED_ROLE ADM DEF
------------------------------ --- ---
SELECT_CATALOG_ROLE NO NO
RESOURCE NO YES
CONNECT NO YES
以上这个就是如上题所显示的结果:SL_REP用户授予了SELECT_CATALOG_ROLE 非默认的角色。
我们再来登录看会不会报错:
sys@OCM> conn SL_REP/SL_REP
Connected.
你看登录是可以了,看上面的视图也可以看出CONNECT是默认的角色了。
SELECT_CATALOG_ROLE是非默认角色,SL_REP是不用直接使用他的
SELECT_CATALOG_ROLE:拥有针对数据字典对象的2000多个对象权限,但没有系统权限或针对用户数据的权限.这对新管理员有用,这些人必须监视数据库并报告数据库情况,但看不到用户数据。
用以上实验再你证明,非默认的角需要激活才能使用,即要设为默认角色才能使用。
[html]
gyj@OCM> conn SL_REP/SL_REP
Connected.
sl_rep@OCM> select * from dba_objects;
select * from dba_objects
*
ERROR at line 1:
ORA-00942: table or view does not exist
sl_rep@OCM> conn / as sysdba
Connected.
gyj@OCM> alter user SL_REP default role connect,resource,SELECT_CATALOG_ROLE;
User altered.
gyj@OCM> conn SL_REP/SL_REP
Connected.
sl_rep@OCM> select * from dba_objects where rownum=1;
OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_ID DATA_OBJECT_ID OBJECT_TYPE CREATED LAST_DDL_TIM TIMESTAMP STATUS T G S NAMESPACE EDITION_NAME
------------------------------ -------------------------------------------------------------------------------------------------------------------------------- ------------------------------ ---------- -------------- ------------------- ------------ ------------ ------------------- ------- - - - ---------- ------------------------------
SYS ICOL$ 20 2 TABLE 17-SEP-11 17-SEP-11 2011-09-17:09:46:13 VALID N N N 1
sl_rep@OCM> select GRANTED_ROLE ,ADMIN_OPTION,DEFAULT_ROLE from dba_role_privs where grantee='SL_REP';
GRANTED_ROLE ADM DEF
------------------------------ --- ---
SELECT_CATALOG_ROLE NO YES
RESOURCE NO YES
CONNECT &nb