通过grant 授于用户的角色,在用户登录时默认是全部继承的,除非是用alter user 显示的修改,指定用户连接后默认的角色有哪些,但是用户也可以使用后使用set role再附加已授权的但没启用的角色用于当前session
下面看我的例子一看就明白了
DEFAULT ROLE Clause
Specify the roles granted by default to the user at logon. This clause can contain only roles that have been granted directly to the user with a GRANT statement. You cannot use the DEFAULT ROLE clause to enable:
•Roles not granted to the user
•Roles granted through other roles
•Roles managed by an external service (such as the operating system), or by the Oracle Internet Directory
Oracle Database enables default roles at logon without requiring the user to specify their passwords or otherwise be authenticated. If you have granted an application role to the user, you should use the DEFAULT ROLE ALL EXCEPT role clause to ensure that, in subsequent logons by the user, the role will not be enabled except by applications using the authorized package.
note: 这与revoke是不一样的,区别是revoke是夺回用户的角色,而deault 只是有角色默认不使用
下面看我的例子一看就明白了
SQL> create role tabview ;
Role created.
SQL> grant create table ,create view to tabview;
Grant succeeded.
SQL> create role con;
Role created.
SQL> grant create session to con;
Grant succeeded.
SQL> create user anbob identified by anbob;
User created.
SQL> grant con,tabview to anbob;
Grant succeeded.
SQL> conn anbob/anbob;
Connected.
SQL> create table test1(id int);
create table test1(id int)
*
ERROR at line 1:
ORA-01950: no privileges on tablespace 'USERS'
SQL> conn system/oracle
Connected.
SQL> alter user anbob quota 10m on users;
User altered.
SQL> conn anbob/anbob
Connected.
SQL> create table test1(id int);
Table created.
SQL> conn system/oracle
Connected.
SQL> alter user anbob default role none;
User altered.
SQL> conn anbob/anbob;
ERROR:
ORA-01045: user ANBOB lacks CREATE SESSION privilege; logon denied
Warning: You are no longer connected to ORACLE.
SQL> alter user anbob default role con;
SP2-0640: Not connected
SQL> conn system/oracle
Connected.
SQL> alter user anbob default role con;
User altered.
SQL> conn anbob/anbob;
Connected.
SQL> create table test2(id int);
create table test2(id int)
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> set role tabview;
Role set.
SQL> create table test2(id int);
Table created.
SQL> conn system/oracle
Connected.
SQL> alter user anbob default role all;
User altered.
SQL> conn anbob/anbob;
Connected.
SQL> create table test3(id int);
Table created.
SQL> conn system/oracle
Connected.
SQL> alter user anbob default role all except tabview;
User altered.
SQL> conn anbob/anbob;
Connected.
SQL> create table test4(id int);
create table test4(id int)
*
ERROR at line 1:
ORA-01031: insufficient privileges复制
DEFAULT ROLE Clause
Specify the roles granted by default to the user at logon. This clause can contain only roles that have been granted directly to the user with a GRANT statement. You cannot use the DEFAULT ROLE clause to enable:
•Roles not granted to the user
•Roles granted through other roles
•Roles managed by an external service (such as the operating system), or by the Oracle Internet Directory
Oracle Database enables default roles at logon without requiring the user to specify their passwords or otherwise be authenticated. If you have granted an application role to the user, you should use the DEFAULT ROLE ALL EXCEPT role clause to ensure that, in subsequent logons by the user, the role will not be enabled except by applications using the authorized package.
note: 这与revoke是不一样的,区别是revoke是夺回用户的角色,而deault 只是有角色默认不使用
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
【纯干货】Oracle 19C RU 19.27 发布,如何快速升级和安装?
Lucifer三思而后行
638次阅读
2025-04-18 14:18:38
Oracle RAC 一键安装翻车?手把手教你如何排错!
Lucifer三思而后行
619次阅读
2025-04-15 17:24:06
Oracle数据库一键巡检并生成HTML结果,免费脚本速来下载!
陈举超
518次阅读
2025-04-20 10:07:02
XTTS跨版本迁移升级方案(11g to 19c RAC for Linux)
zwtian
518次阅读
2025-04-08 09:12:48
【ORACLE】记录一些ORACLE的merge into语句的BUG
DarkAthena
476次阅读
2025-04-22 00:20:37
Oracle 19c RAC更换IP实战,运维必看!
szrsu
453次阅读
2025-04-08 23:57:08
【活动】分享你的压箱底干货文档,三篇解锁进阶奖励!
墨天轮编辑部
451次阅读
2025-04-17 17:02:24
一页概览:Oracle GoldenGate
甲骨文云技术
450次阅读
2025-04-30 12:17:56
【ORACLE】你以为的真的是你以为的么?--ORA-38104: Columns referenced in the ON Clause cannot be updated
DarkAthena
448次阅读
2025-04-22 00:13:51
火焰图--分析复杂SQL执行计划的利器
听见风的声音
396次阅读
2025-04-17 09:30:30
热门文章
移除DataGuard Standby配置导致Primary启动失败
2023-08-17 21335浏览
使用dblink产生的”SELECT /*+ FULL(P) +*/ * FROM XXXXX P ” 解析
2023-06-20 20901浏览
Troubleshooting 'ORA-28041: Authentication protocol internal error' change password 12c R2 DB
2020-04-08 13685浏览
浅谈ORACLE免费数据库Oracle Database XE (Express Edition) 版
2018-10-31 7651浏览
High wait event ‘row cache mutex’ in 12cR2、19c
2020-08-14 5599浏览