oracle10g和11g关于角色口令的区别
来源:互联网 发布:计量经济学第四版数据 编辑:程序博客网 时间:2024/06/06 00:30
这个 角色的密码, 一般是这种情况的:一个用户,有 默认角色 与 非默认角色 2种。默认角色,就是当用户登录的时候,就自动拥有的角色非默认角色,就是当用户登录的时候,用户需要通过 SET Role 来启用这个角色。例如,你同时被授予了 A,B,C 三个角色。 A 为默认角色。 B,C非默认。你每次登录, 自动被赋予了 A 这个角色。B, C 这2个角色, 是要通过 SET Role 语句 启用这个角色。 对于 oracle里角色的密码就是 当你 SET Role 启用角色的时候,如果这个 角色是有密码的, 你需要输入 角色的密码, 来启用这个角色。
角色是一组相关权限的命名集合,使用角色最主要的目的是简化权限管理
而一旦这个集合的权限超过了用户的最低需求,就可能带来数据库的安全风险
角色口令测试
oracle 10g中,无论角色是否有口令,只要你将角色grant给某个用户,那么,默认的情况下,这些角色中的权限,用户都拥有。
oracle 11g中,角色的口令略有修正,当某个角色是拥有口令的话,当你将带有口令的角色 grant 给某个用户的话,那么默认的情况
下,这个带口令的角色下的所有权限,用户是无法拥有的,只有当 set 那个拥有口令的角色后,那么 ,带口令的
角色下的权限才在当前会话下才可以使用,不过,其他的角色都暂时失效,修改只在当前会话有效。
1<strong>语法: </strong><strong>
------只在当前会话有效</strong>
1SET
ROLE
12345{ role [ <strong>IDENTIFIED
BY
</strong>
password
]
[, role [ <strong>IDENTIFIED
BY
</strong>
password
] ]...
| <strong>
ALL
</strong> [ <strong>
EXCEPT
</strong> role [, role ]... ]
| <strong>NONE</strong>
} ;
oracle 10g 中测试带口令的角色
SYS@ORCL>select * from v$version;BANNER----------------------------------------------------------------Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProdPL/SQL Release 10.2.0.1.0 - ProductionCORE 10.2.0.1.0 ProductionTNS for Linux: Version 10.2.0.1.0 - ProductionNLSRTL Version 10.2.0.1.0 - Production
1. 创建两个角色 role_01 没有密码 role_02 有密码
SYS@ORCL>create role role_01;Role created.SYS@ORCL>create role role_02 identified by oracle;Role created.2. 赋予角色 role_01 连接、建表权限SYS@ORCL>grant connect,create table to role_01;Grant succeeded.3. 赋予角色 role_02 连接、创建视图权限SYS@ORCL>grant connect,create view to role_02;Grant succeeded.4. 创建测试用户 tygerSYS@ORCL>create user tyger identified by tyger quota unlimited on users;User created.5. 将两个角色赋予tygerSYS@ORCL>grant role_01,role_02 to tyger;Grant succeeded.6. 连接到用户测试SYS@ORCL>conn tyger/tygerConnected.TYGER@ORCL>create table t(x int);Table created.TYGER@ORCL>insert into t values(1);1 row created.TYGER@ORCL>commit;Commit complete.TYGER@ORCL>select * from t;X----------1TYGER@ORCL>create view view_t as select * from t;View created.TYGER@ORCL>select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------VIEW_T VIEWT TABLE7. 查看当前用户的角色,两个角色的 DEFAULT_ROLE 都为 YES 说明,这两个角色都生效TYGER@ORCL>desc user_role_privs;Name Null? Type----------------------------------------- -------- ----------------------------USERNAME VARCHAR2(30)GRANTED_ROLE VARCHAR2(30)ADMIN_OPTION VARCHAR2(3)DEFAULT_ROLE VARCHAR2(3)OS_GRANTED VARCHAR2(3)TYGER@ORCL>col username for a10TYGER@ORCL>col granted_role for a20TYGER@ORCL>col default_role for a20TYGER@ORCL>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER ROLE_01 YESTYGER ROLE_02 YES8. 查看当前会话具有的权限TYGER@ORCL>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE TABLECREATE VIEW9. set 的应用 ----set 在当前会话中设置角色状态TYGER@ORCL>set role ROLE_01;Role set.10. 查看当前用户的角色,没变化TYGER@ORCL>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER ROLE_01 YESTYGER ROLE_02 YES11. 查看当前会话权限,已经没有 create view 权限, 原因:set role role_01 只有role_01 在当前会话生效TYGER@ORCL>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE TABLETYGER@ORCL>create view view_2 as select * from t;create view view_2 as select * from t*ERROR at line 1:ORA-01031: insufficient privileges12. 同样使 role_02 生效,同时 role_01 失效,不过设置的时候需要我们提供密码,因为我们创建角色时使用了密码TYGER@ORCL>set role role_02;set role role_02*ERROR at line 1:ORA-01979: missing or invalid password for role 'ROLE_02'TYGER@ORCL>set role role_02 identified by oracle;Role set.13. 查看当前用户所拥有的权限,还是没变化TYGER@ORCL>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER ROLE_01 YESTYGER ROLE_02 YES14. 查看当前会话的权限,已经没有 create table 权限TYGER@ORCL>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE VIEWTYGER@ORCL>create table t1(x int);create table t1(x int)*ERROR at line 1:ORA-01031: insufficient privileges15. 重新登录会话,连接用户 所有权限都恢复原样TYGER@ORCL>conn tyger/tyger;Connected.TYGER@ORCL>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE TABLECREATE VIEW
总结:在oracle 10g 无论角色是否有口令,将角色赋予给用户后,用户具有角色的全部权限。
oracle 11g 中测试 拥有口令的角色
[oracle@ora11gr2 ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 19 15:28:13 2014Copyright (c) 1982, 2009, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSYS@ORA11G>select * from v$version;BANNER--------------------------------------------------------------------------------Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - ProductionPL/SQL Release 11.2.0.1.0 - ProductionCORE 11.2.0.1.0 ProductionTNS for Linux: Version 11.2.0.1.0 - ProductionNLSRTL Version 11.2.0.1.0 - Production1. 创建角色 tyger_ro1 无密码 tyger_ro2 有密码SYS@ORA11G>create role tyger_ro1;Role created.SYS@ORA11G>create role tyger_ro2 identified by oracle;Role created.SYS@ORA11G>grant connect,create table to tyger_ro1;Grant succeeded.SYS@ORA11G>grant connect,create view to tyger_ro2;Grant succeeded.SYS@ORA11G>create user tyger identified by tyger quota unlimited on users;User created.SYS@ORA11G>grant tyger_ro1,tyger_ro2 to tyger;Grant succeeded.SYS@ORA11G>conn tyger/tygerConnected.TYGER@ORA11G>create table t(x int);Table created.TYGER@ORA11G>insert into t values(1);1 row created.TYGER@ORA11G>commit;Commit complete.2. 此时就出现问题了,role_02 明明有 create view 而且赋予给了 tyger 为什么这里就没有呢?TYGER@ORA11G>create view view_t as select * from t;create view view_t as select * from t*ERROR at line 1:ORA-01031: insufficient privileges3. 查看 tyger_ro2 的default_role 为NO 难道 role_02 角色失效???TYGER@ORA11G>col username for a10TYGER@ORA11G>col granted_role for a20TYGER@ORA11G>col default_role for a20TYGER@ORA11G>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER TYGER_RO1 YESTYGER TYGER_RO2 NO4. 再查看当前会话的权限,果然没有 create view 权限TYGER@ORA11G>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE TABLE5. 设置 tyger_ro2 权限生效TYGER@ORA11G>set role tyger_ro2 identified by oracle;Role set.6. 当前用户具有的权限不变TYGER@ORA11G>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER TYGER_RO1 YESTYGER TYGER_RO2 NO7.当前会话用了 create view 权限 却没有了create table 权限TYGER@ORA11G>select * from session_privs;PRIVILEGE----------------------------------------CREATE SESSIONCREATE VIEWTYGER@ORA11G>create view view_t as select * from t;View created.TYGER@ORA11G>select * from tab;TNAME TABTYPE CLUSTERID------------------------------ ------- ----------T TABLEVIEW_T VIEWTYGER@ORA11G>create table t1(x int);create table t1(x int)*ERROR at line 1:ORA-01031: insufficient privileges8. 重新登录会话,权限恢复原样TYGER@ORA11G>conn tyger/tygerConnected.TYGER@ORA11G>create table t1(x int);Table created.TYGER@ORA11G>select username,granted_role,default_role from user_role_privs;USERNAME GRANTED_ROLE DEFAULT_ROLE---------- -------------------- --------------------TYGER TYGER_RO1 YESTYGER TYGER_RO2 NO
总结:
在oracle 11g 中,带有口令的角色赋予用户,默认情况下是失效的,当 set role 生效后,其他角色所具有的权限失效, 只在当前会话有效
- oracle10g和11g关于角色口令的区别
- oracle10g和11g关于角色口令的区别
- oracle 10g 和 11g 关于角色口令的区别
- oracle 10g 和 11g 关于角色口令的区别
- oracle817和oracle10g的区别
- sql plus修改用户名和密码-orcale 11g修改用户名和口令的方法
- 密码、口令和令牌的区别?
- oracle10g、11g的安装步骤
- oracle10G 11G drop表的恢复
- ORACLE10G导入11G导出的文件
- 角色和组的区别
- 11g口令区分大小写
- Oracle 11g ORA-28002:口令将过期的解决方法
- 如何在同一台计算机上的oracle10g和11g之间进行oracle环境切换
- Oracle10g和11g在新增表字段时default的性能影响
- Oracle10G 11G下载链接-多平台下的32位和64位
- 如何在同一台计算机上的oracle10g和11g之间进行oracle环境切换
- 关于修改sys口令和口令文件之间关系的实验
- C++ - string类型转换int类型
- 安卓随手笔记 一
- android 异步任务 AsyncTask
- c#插件式程序开发(二):如何在插件中调用主程序资源
- Scrapy: 发送带Cookie的请求
- oracle10g和11g关于角色口令的区别
- ACdream 计算最长非连续相同字符的个数
- Xianfeng轻量级Java中间件平台:菜单管理
- 单线程与多线程
- Binary String Matching
- cocos2dx-3.0(13)------容器Vector和Map
- 写下自己对链表的操作吧
- 黑马程序员_IO流
- pipe row的用法, Oracle split 函数写法