ORA-01536

java.sql.SQLException: ORA-01536: space quota exceeded for tablespace 'xxx'


看到这行错误信息,第一反应是表空间满了,然后去查数据库,发现此表空间使用率才只有5.59%,非常疑惑,然后查了服务器磁盘剩余空间也还有很多,顿时有点懵。随手看了下dba_ts_quotas,靠!原来是该用户没有此表空间的权限。赋权后(顺手给了个unlimited),问题解决。



附几条sql语句做纪念吧:

1、格式化输出

set echo off;
set feedback off;
set termout off;
set heading on;
set term off;

set linesize 150;
set pagesize 100;

column TABLESPACE_NAME format a20;
column MAX_FILE_SPACE format a20;

2、表空间使用情况查询sql

select d.tablespace_name,
       to_char(space,'fm9999990.00')||'MB' sum_space,
       to_char((space-nvl(free_space,0)),'fm9999990.00')||'MB' used_space,
       to_char((round((1-nvl(free_space,0)/space)*100,2)),'fm990.00')||'%' used_rate,
       to_char(free_space,'fm9999990.00')||'MB' free_space,
       s.SEGMENT_SPACE_MANAGEMENT SEGMENT,
       to_char(maxspace)||'MB' max_file_space,
       d.data_file_count
  from (select tablespace_name,round(sum(bytes)/(1024*1024),2) space,sum(blocks) blocks
               ,round(sum(maxbytes)/(1024*1024),2) maxspace,count(FILE_ID) data_file_count
           from dba_data_files group by tablespace_name) d,
       (select tablespace_name,round(sum(bytes)/(1024*1024),2) free_space
           from dba_free_space group by tablespace_name) f,
       (select TABLESPACE_NAME,SEGMENT_SPACE_MANAGEMENT from dba_tablespaces) s
  where d.tablespace_name = f.tablespace_name and
        f.tablespace_name = s.tablespace_name
        ;

3、赋权

select * from dba_ts_quotas;

alter user 用户名 quota unlimited on 表空间名; (quota可以设置具体字节数,也可以设置无限unlimited)

你可能感兴趣的:(表空间,ora,01536)