现在的位置: 首页 > 综合 > 正文

由 ORA-01536: space quota exceeded for tablespace 引出的研究

2014年02月21日 ⁄ 综合 ⁄ 共 2747字 ⁄ 字号 评论关闭

研发的同事说建表时数据库报错:ORA-1536

 

[oracle@localhost ~]$ oerr
ora 1536

01536, 00000, "space quota exceededfor tablespace '%s'"

// *Cause: The space quota for the segment owner in the tablespace has

//         been exhausted and the operation attempted the creation of a

//         new segment extent in the tablespace.

// *Action: Either drop unnecessary objectsin the tablespace to reclaim

//         space or have a privileged user increase the quota on this

//         tablespace for the segment owner.

 

 

用户表空间配额不足。有点奇怪,不过还是先解决问题,解决问题有三种方法:

 

方法一:SQL> alteruser user_name quota unlimited on tablespace_name;

方法二:SQL> alteruser user_name quota 100M on tablespace_name;

方法三:SQL> grantunlimited tablespace to user_name;

 

关于quota,之前有整理blog,参考:

Oracle
用户 对 表空间 配额(quota) 说明

http://blog.csdn.net/xujinyang/article/details/6829277

 

我给用户grant
unlimited tablespace 之后,问题解决。现在我们要研究一下这个问题。之前我给这个用户赋了connect,resource,dba 三个角色。有关用户角色的详细内容参考:

Oracle
用户及角色 介绍

http://blog.csdn.net/xujinyang/article/details/6830114

           

         然后回收了dba的角色,用户在建表就报了ORA-1536的错误。

 

在我们创建用户时,默认是会授予unlimited
tablespace 的权限的,但是如果我们赋予了用户DBA的角色,然后revokedba 角色之后,那么unlimitedtablespace的权限也会被revoke。 因为unlimited tablespace的权限是在DBA 角色下面的。这个就是遇到ORA-1536的一个原因。

 

在我们赋给了unlimitedtablespace
权限之后,查看dba_ts_quotas表:

 SQL> grant unlimited tablespace to dave;

Grant succeeded.

SQL> select
* from dba_sys_privs where grantee='DAVE';

GRANTEE                       PRIVILEGE                     ADM

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

DAVE                UNLIMITED TABLESPACE           NO

 

SQL> select
username, tablespace_name,bytes, max_bytes from dba_ts_quotas where username = 'DAVE';

no rows selected

 

返回为空。
在查看user_ts_quotas:

SQL> conn dave/dave;

Connected.

SQL> select tablespace_name, bytes,max_bytes from USER_TS_QUOTAS;

no rows selected

 

还是为空。我们测试使用alter
user 命令修改quota 的配置:

SQL> alter
user dave quota unlimited on system;

User altered.

 

在查看dba_ts_quots:

SQL> select username, tablespace_name,bytes, max_bytes from dba_ts_quotas where username = 'DAVE';

 

USERNAME                       TABLESPACE_NAME                     BYTES  MAX_BYTES

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

DAVE                           SYSTEM                                  0         -1

 

这时就可以查看到相关的记录了,这里的-1
表示unlimited。

 

在修改配额:

SQL> alter
user dave quota 50M on system;

User altered.

 

SQL> select * from user_ts_quotas;

 

TABLESPACE_NAME               BYTES  MAX_BYTES    BLOCKS MAX_BLOCKS DRO

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

SYSTEM                                  0   52428800          0       6400 NO

 

测试我们的配额就变成了50M.

 

 

小结:

1.     创建用户默认会授予unlimited tablespace 的权限,但如果分配了DBA的角色,在收回DBA 角色时,unlimited tablespace 的角色也会同时收回。

2.     如果只对用户赋予了unlimited tablespace的权限,那么在user_ts_quotas和 dba_ts_quotas 表里都没有相关的记录,只有修改quota 之后,这2个字典里才会有相关的quota 信息。

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

抱歉!评论已关闭.