您的位置:首页 > 其它

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

2011-12-01 13:43 495 查看
研发的同事说建表时数据库报错: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) 说明
/article/1361858.html


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

然后回收了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='D***E';
GRANTEE PRIVILEGE ADM
---------------------------------------------------------------------- ---
D***E UNLIMITED TABLESPACE NO

SQL> select username, tablespace_name,bytes, max_bytes from dba_ts_quotas where username = 'D***E';
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 = 'D***E';

USERNAME TABLESPACE_NAME BYTES MAX_BYTES
------------------------------------------------------------ ---------- ----------
D***E 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 信息。







-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog: http://blog.csdn.net/tianlesoftware Weibo: http://weibo.com/tianlesoftware Email: tianlesoftware@gmail.com
Skype: tianlesoftware

-------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----
DBA1 群:62697716(满); DBA2 群:62697977(满) DBA3 群:62697850(满)
DBA 超级群:63306533(满); DBA4 群:83829929 DBA5群: 142216823
DBA6 群:158654907 DBA7 群:172855474 DBA8群:102954821
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: