系统权限与对象权限的revoke机制比较

下面谈谈关于系统权限与对象权限的revoke 差别。

1 、系统权限的撤销:

收回系统权限时,没有级联效果。什么是级联效果呢?就是当我(sys )将某一系统权限(create table )授予给用户test1 后(使用with admin option ,这样的话test1 可以将此权限再授予第三个用户),test1 又将此权限授予给第三者(test2 ),这不同于sys 直接对test2 授予create table 。当我们收回test1create table 权限时,test1 以前创建的表仍然存在,但无法创建新表,而test 仍然用于create table 的权限。下面来看看这个过程:

创建用户test1 ,并授予基本的权限,然后授予将权限create table 授予给其他用户的with admin option 权限。

SQL> create user test1 identified by test1 default tablespace data;

用户已创建

SQL> grant create session,unlimited tablespace to test1;

授权成功。

SQL> grant create table to test1 with admin option;

授权成功。

SQL> create user test2 identified by test2 default tablespace data;

用户已创建

SQL> grant create session,unlimited tablespace to test2;

授权成功。

SQL> conn test1/test1@company;

已连接。

SQL> create table t1(id number);

表已创建。

SQL> grant create table to test2;

授权成功。

SQL> conn test2/test2@company;

已连接。

SQL> create table t2(id number);

表已创建。

SQL> conn sys/oracle@company as sysdba

已连接。

SQL> revoke create table from test1;

撤销成功。

SQL> conn test1/test1@company;

已连接。

SQL> select table_name from user_tables;

TABLE_NAME                                                                     

------------------------------------------------------------                    

T1                                                                             

SQL> create table t3(id number);

create table t3(id number)

*

ERROR 位于第 1 :

ORA-01031: insufficient privileges

SQL> insert into t1 values(1);

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from session_privs;

PRIVILEGE                                                                      

----------------------------------------------------------------------------

CREATE SESSION                                                                  

UNLIMITED TABLESPACE     

SQL> conn test2/test2@company;

已连接。

SQL> select table_name from user_tables;

TABLE_NAME                                                                     

------------------------------------------------------------                   

T2                                                                             

SQL> create table t4 as select * from t2;

表已创建。

SQL> insert into t2 values(1);

已创建 1 行。

SQL> select * from session_privs;

PRIVILEGE                                                                       

----------------------------------------------------------------------------

CREATE SESSION                                                                 

UNLIMITED TABLESPACE                                                            

CREATE TABLE                                                                   

 

总结:系统权限的回收不存在级联关系,只能回收直接授权的。                                               

 

2 、对象权限的撤销:

   回收对象权限时,存在级联操作。先看过程:

SQL> show user;

USER "TEST1"

SQL> conn sys/oracle@company as sysdba

已连接。

SQL> grant dba to scott;

授权成功。

SQL> conn scott/tiger@company;

已连接。                                                                

SQL> select count(*) from test_pk;

  COUNT(*)                                                                     

----------                                                                      

      1000                                                                     

SQL> grant select on test_pk to test1 with admin option;

grant select on test_pk to test1 with admin option

                                      *

ERROR 位于第 1 :

ORA-00993: missing GRANT keyword

注意此处与系统权限不一样!系统权限是with admin option

对象权限是with grant option

SQL> grant select on test_pk to test1 with grant option;

授权成功。

SQL> conn test1/test1@company;

已连接。

SQL> select count(*) from scott.test_pk;

  COUNT(*)                                                                      

----------                                                                     

      1000                                                                     

SQL> conn test2/test2@company;

已连接。

SQL> select count(*) from scott.test_pk;

select count(*) from scott.test_pk

                           *

ERROR 位于第 1 :

ORA-00942: table or view does not exist    ————此时还没有授权,报错正常。

test1test2 授予查看scott.test_pk 的权限。

SQL> conn test1/test1@company;

已连接。

SQL> grant select on scott.test_pk to test2;

授权成功。

SQL> conn test2/test2@company;

已连接。

SQL> select count(*) from scott.test_pk;

  COUNT(*)                                                                     

----------                                                                      

      1000                                                                     

SQL> conn scott/tiger@company;

已连接。

SQL> revoke select on test_pk from test1;

撤销成功。

SQL> conn test1/test1@company;

已连接。

SQL> select count(*) from test1;

select count(*) from test1

                     *

ERROR 位于第 1 :

ORA-00942: table or view does not exist     ----- 这个权限已经回收,所以报错!

SQL> conn test2/test2@company;

已连接。

SQL> select count(*) from scott.test_pk;

select count(*) from scott.test_pk

                            *

ERROR 位于第 1 :

ORA-00942: table or view does not exist     ----- 这个权限也被级联回收,所以报错!

SQL> select * from v$version;

BANNER                                                                         

-------------------------------------------------------------------------

Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production                     

PL/SQL Release 9.2.0.4.0 - Production                                          

CORE  9.2.0.3.0   Production                                                       

TNS for Linux: Version 9.2.0.4.0 - Production                                  

NLSRTL Version 9.2.0.4.0 - Production           

 

总结:在回收对象权限时,存在级联回收!也就是说如果用户scott 将查看test_pk 表的权限授予给test1 用户,并且授予其可以再将此权限授予给其他用户的权限,也就是with grant option 。此时test1 将查看test_pk 表的权限授予给test2 用户。当scott 回收test1 查看test_pk 表的权限时,test2 查看test_pk 表的权限同时被回收。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值