Oracle drop table 和 truncate table对grant授权的影响

1、以sys登陆,建表赋予权限,准备测试表z2

[oracle@crl ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 14:59:27 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table z2 as select 1 as a from dual;

Table created.

SQL> grant select on z2 to dwetl;

Grant succeeded.

SQL> 


2、以dwetl账号登陆,对表进行查询权限,查询OK,能访问数据

[oracle@crl ~]$ rlwrap sqlplus 'dwetl/"pwd2017"'@DB1

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 14:59:01 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from sys.z2;

	 A
----------
	 1

SQL> 


3、再以sys登陆,删除表z2后,再次建立表z2

[oracle@crl ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 14:59:27 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> drop table sys.z2;

Table dropped.

SQL> create table z2 as select 1 as a from dual;

Table created.

SQL>
SQL> select * from sys.z2;

	 A
----------
	 1

SQL> 


4、再以dwetl登陆,看是否可以查询到,答案是查不到,报错表或者视图不存在

[oracle@crl ~]$ rlwrap sqlplus 'dwetl/"pwd2017"'@DB1

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 15:03:10 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from sys.z2;
select * from sys.z2
                  *
ERROR at line 1:
ORA-00942: table or view does not exist


SQL> 


5,再次以sys登陆,赋予表z2给dwetl的权限

[oracle@crl ~]$ rlwrap sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 15:14:16 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> grant select on z2 to dwetl;

Grant succeeded.

SQL> 


6,再次以dwetl登陆,尝试是否可以查询到sys.z2表,OK,可以查询到数据了

[oracle@crl ~]$ rlwrap sqlplus 'dwetl/"pwd2017"'@DB1

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 15:14:57 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from sys.z2;

	 A
----------
	 1

SQL> 



7、truncate对权限有无影响?

以sys登陆,执行truncate操作表z2,然后退出,以dwetl登陆查询表z2,发现可以执行select操作

SQL> truncate table z2;

Table truncated.

SQL> exit
ERROR:
ORA-04088: error during execution of trigger 'TIMDBA.TRIG_LOGOFF_AUDIT'
ORA-01403: no data found
ORA-06512: at line 5


Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options (with complications)
[oracle@crl ~]$ rlwrap sqlplus 'dwetl/"pwd2017"'@DB1

SQL*Plus: Release 11.2.0.4.0 Production on Tue May 16 15:18:08 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select * from sys.z2;

no rows selected

SQL> 


以上测试实验结论标识:

(1):当表被drop掉后,别的用户对这个表的操作权限失效了,请记得重新grant下权限,不然另外的用户就无法对表进行操作;


(2):当表被truncate之后,别的用户对这张表的操作权限依然有效。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值