1、角色新建
sql> create role clerk;
Role created
sql> create role sales;
Role created
sql> create role manager;
Role created
sql> select * from dba_roles where role in('CLERK','SALES','MANAGER');
ROLE PASSWORD_required AUTHENTICATION_TYPE
------------------------------ ----------------- -------------------
CLERK NO NONE
SALES NO NONE
MANAGER NO NONE
2、修改
sql> ALTER role manager identified by manager;
Role altered
查看
sql> select * from dba_roles where role in('CLERK','MANAGER');
ROLE PASSWORD_required AUTHENTICATION_TYPE
------------------------------ ----------------- -------------------
CLERK NO NONE
SALES NO NONE
MANAGER YES PASSWORD
3、授权
sql> grant create session,create table,create view to clerk;
Grant succeeded
sql> grant select any table,clerk to manager;
Grant succeeded
查看
sql> select * from role_sys_privs where role in('CLERK','MANAGER');
ROLE PRIVILEGE ADMIN_OPTION
------------------------------ -------------------- ------------
CLERK CREATE TABLE NO
CLERK CREATE VIEW NO
CLERK CREATE SESSION NO
MANAGER SELECT ANY TABLE NO
查看授权来源
sql> select * from dba_role_privs where granted_role like 'CL%';
GRANTEE GRANTED_RO ADMIN_OPTION DEFAULT_ROLE
---------- ---------- ------------ ------------
MANAGER CLERK NO YES
SYS CLERK YES YES
4、默认角色
sql> alter user cat default role all;
User altered
5、角色回收 revoke manager from pig; 原文链接:https://www.f2er.com/oracle/207585.html