日期:2014-05-16 浏览次数:20361 次
转载请注明出处:http://blog.csdn.net/guoyjoe/article/details/11663717
正确答案:A
启用角色
默认方式下,如果为用户授予了角色,则将启用角色。这意味着,在建立了连接用户账户的会话的时,将激活授予此角色的所有权限和其它角色。通过将角色设置为非默认来修改此行为。下面的查询接着前面给出的示例。显示已为SL_REP授予了什么角色。
1、创建用户SL_REP
gyj@OCM> create user SL_REP identified by SL_REP default tablespace users; User created.
gyj@OCM> grant resource,connect to SL_REP; Grant succeeded. gyj@OCM> grant SELECT_CATALOG_ROLE to SL_REP; Grant succeeded.
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
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.
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多个对象权限,但没有系统权限或针对用户数据的权限.这对新管理员有用,这些人必须监视数据库并报告数据库情况,但看不到用户数据。
用以上实验再你证明,非默认的角需要激活才能使用,即要设为默认角色才能使用。
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 TABL