Oracle执行脚本时遇到ORA-01653: unable to extend table X by Y in tablespace错误

来源:互联网 发布:aoi编程手册 编辑:程序博客网 时间:2024/05/16 09:34

问题描述:insert操作数据量为1000000,delete数据量亦为1000000,同时执行,一段时间后,delete完成后,insert操作后面报错,ORA-01653: unable to extend table X by Y in tablespace,看提示信息是表空间不足,现提供几个sql来查看相关信息,便于定位问题。

一、查询表空间相关信息

SELECT a.tablespace_name ,
      a.bytes / 1024 / 1024                              Total_tablespace,--表空间大小(M)
      ( a.bytes - b.bytes ) / 1024 / 1024                Used_tablespace,--已使用空间(M)
      b.bytes / 1024 / 1024                              Idel_tablespace,--空闲空间(M)
      Round(( ( a.bytes - b.bytes ) / a.bytes ) * 100, 2) UseRate_tablespace--使用比率
FROM  (SELECT tablespace_name,
              SUM(bytes) bytes
        FROM  dba_data_files
        GROUP  BY tablespace_name) a,
      (SELECT tablespace_name,
              SUM(bytes) bytes,
              Max(bytes) largest
        FROM  dba_free_space
        GROUP  BY tablespace_name) b
WHERE  a.tablespace_name = b.tablespace_name
ORDER  BY ( ( a.bytes - b.bytes ) / a.bytes ) DESC;

二、查看表空间对应的datafile的信息

select file_name,tablespace_name,bytes/1024/1024,maxbytes/1024/1024 from dba_data_files where tablespace_name='USERS';

三、查看表空间对应的datafile是否可以自动扩展(当然有些场景开启自动扩展功能可能会带来一些潜在的问题,所以不是所有公司都开启这个)

select file_id,file_name,tablespace_name,autoextensible,increment_by from dba_data_files where tablespace_name ='USERS' order by file_id desc;

0 0
原创粉丝点击