11.2.0.2版本修改回收UNLIMITED TABLESPACE功能

11.2.0.2的环境中,碰到了这个问题,使用REVOKE UNLIMITED TABLESPACE命令后,发现设置的用户QUOTA也消失了。

 

 

这是一个实际的案例,在客户的环境中新建了一个用户,准备导入一些数据,结果碰到了问题:

SQL> create user thams account unlock identified by thams default tablespace LOB_AU2M quota unlimited on LOB_AU2M;

User created.

SQL> grant connect,resource to thams;

Grant succeeded.

SQL> grant create view,create synonym,create database link to thams;

Grant succeeded.

SQL> revoke unlimited tablespace from thams;

Revoke succeeded.

SQL> grant read,write on directory expdir to thams;

Grant succeeded.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
[oracle@dbserver1 oracle-export]$ impdp thams/thams dumpfile=AMS-ORA9_20110815_2.DP logfile=AMS-ORA9_20110815_2_imp.log directory=expdir remap_tablespace=THAMS:LOB_AU2M remap_tablespace=users:lob_au2m

Import: Release 11.2.0.2.0 - Production on Tue Aug 16 12:36:41 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
ORA-39006: internal error
ORA-39068: invalid master table data in row with PROCESS_ORDER=-4
ORA-01536: space quota exceeded for tablespace 'LOB_AU2M'

ORA-39097: Data Pump job encountered unexpected error -1536

刚看到这个错误的时候十分疑惑,明明在创建用户的时候指定了LOB_AU2M表空间上的无限制的QUOTA,怎会仍然会出现这个错误呢。

但是检查数据库,确实没有发现无限QUOTA的存在:

[oracle@dbserver1 oracle-export]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue Aug 16 12:38:29 2011

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

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

SQL> set pages 100 lines 120
SQL> select * from dba_ts_quotas;

TABLESPACE_NAME      USERNAME                BYTES  MAX_BYTES     BLOCKS MAX_BLOCKS DRO
-------------------- ------------------ ---------- ---------- ---------- ---------- ---
SYSAUX               SYSMAN               76480512         -1       9336         -1 NO
SYSAUX               APPQOSSYS                   0         -1          0         -1 NO

SQL> ALTER USER THAMS QUOTA UNLIMITED ON LOB_AU2M;

User altered.

SQL> select * from dba_ts_quotas;

TABLESPACE_NAME      USERNAME                BYTES  MAX_BYTES     BLOCKS MAX_BLOCKS DRO
-------------------- ------------------ ---------- ---------- ---------- ---------- ---
SYSAUX               SYSMAN               76480512         -1       9336         -1 NO
SYSAUX               APPQOSSYS                   0         -1          0         -1 NO
LOB_AU2M             THAMS      0         -1 NO

对用户重新设置QUOTA后,问题解决,数据加载也顺利完成。

不过对于为什么QUOTA会消失比较困惑,开始曾经以为是CREATE USERACCOUNT UNLOCK的语法存在一些问题,导致QUOTA UNLIMITED ON语句失效。正常情况下ACCOUNT UNLOCK应该放到IDENTIFIED语句的后面,不过测试发现问题和这里的语法并没有关系,导致问题的原因实际上是由于REVOKE UNLIMITED TABLESPACE权限所致。

在我的印象中,以前版本的数据库并不存在这个问题,因此认为可能是11.2bug;不过“ORA-600”认为,目前的这种现象也可以解释得通,很可能是Oracle为了强化安全而对于UNLIMITED TABLESPACE权限做的修改。

为此特地查询了Oracle的文档,结果发现是600对了,这个功能的修改是11.2.0.2的新特性,从11.2.0.2开始,如果回收了UNLIMITED TABLESPACE权限,那么这个用户的所有QUOTA同时被清除。这意味着在11.2.0.2以后的版本中,在回收UNLIMITED TABLESPACE权限或者RESOURCEDBA角色的时候,应该先检查当前用户所拥有的QUOTA,以便于回收权限后,恢复用户原有的QUOTA属性。

 

请使用浏览器的分享功能分享到微信等