1、以SYSTEM用户登录数据库
sqlplus system/password
2、创建用户test1,默认表空间是users,默认的临时表空间是TEMP,在USERS表空间用1M的限额。
SQL>create user test1 identified by test1 default tablespace users temporary tablespace temp quota 1M on users;
3、创建用户test2,默认表空间是users,默认的临时表空间是TEMP,在USERS表空间用1M的限额。
SQL>create user test2 identified by test2 default tablespace users temporary tablespace temp quota 1M on users;
4、测试系统权限
授权test1用户建立会话权限并有管理选项
SQL>grant create session to test1 with admin option;
SQL>conn test1/test1 (看看test1是否可以连接)
SQL>grant create session to test2;(用test1授权create session 给test2)
SQL>conn test2/test2
SQL>conn system/password
SQL>revoke create session from test1;(撤销test1的连接权限)
SQL>conn test1/test1
ERROR:
ORA-01045: user TEST1 lacks CREATE SESSION privilege; logon denied
警告: 您不再连接到 ORACLE。
SQL>conn test2/test2
test2还可以连接,说明系统权限不支持级联收回
SQL>conn system/password
SQL> revoke create session from test2;(dba 可以跨级收回权限)
SQL> conn test2/test2
ERROR:
ORA-01045: user TEST2 lacks CREATE SESSION privilege; logon denied
警告: 您不再连接到 ORACLE。
5、对象权限测试
SQL> conn system/password
SQL> create table t1 (id number);
表已创建。
SQL> insert into t1 values(10);
已创建 1 行。
SQL> commit;
提交完成。
(在SYSTEM用户下创建一个表)
SQL> grant create session to test1,test2;
SQL> grant select on t1 to test1 with grant option;(授给test1有查看权限,并且有管理选项)
SQL> conn test1/test1
SQL> select * from system.t1;
ID
----------
10
SQL> grant select on system.t1 to test2;
SQL> conn test2/test2
已连接。
SQL> select * from system.t1;
ID
----------
10
SQL> conn system/password
已连接。
SQL> revoke select on t1 from test2;
revoke select on t1 from test2
*
第 1 行出现错误:
ORA-01927: 无法 REVOKE 您未授权的权限
SQL> revoke select on t1 from test1;
撤销成功。
SQL> conn test1/test1
SQL> select * from system.t1;
select * from system.t1
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
SQL> conn test2/test2
已连接。
SQL> select * from system.t1;
select * from system.t1
*
第 1 行出现错误:
ORA-00942: 表或视图不存在
总结:系统权限admin option不支持级联收回,但支持跨级收回
对象权限 grant option 不支持跨级收回,但支持级联收回