为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:
【操作系统】:
【CPU】:
【问题描述】*:表空间还有空间,但是插入数据提示 out of space
表空间使用率查询
文件系统使用查询
该问题与某些底层算法有关,可尝试通过以下两个替代算法查询,由于内容过长分开发
tablespace空间查询
declare
v_xdesno bigint;
v_rowno bigint;
type myrec_t is record(tsid int,fileid int,pageid bigint,block_used bigint,block_free bigint,block_alloc bigint,block_total bigint);
type myarr_t is array myrec_t[];
myarr myarr_t;
PAGE VARBINARY;
v_tsname varchar(100);
v_tsid int;
v_fileid int;
v_pageid bigint;
v_block_used int;
v_block_free int;
v_block_alloc int;
v_full_used bigint;
v_full_free bigint;
v_alloc bigint;
v_total bigint;
mydesc_addr_arr dbms_space.page_addr_arr_t;
mydesc_item_arr dbms_page.desc_item_arr_t;
v_myrec myrec_t;
begin
v_rowno := 1;
select sum(decode(total_size/DBMS_SPACE.PAGE_N_GET(),0,1,total_size/DBMS_SPACE.PAGE_N_GET())) into v_xdesno from v$datafile;
print v_xdesno;
myarr = new myrec_t[v_xdesno];
for f in (select NAME,GROUP_ID TS_ID,a.ID FILE_ID,a.TOTAL_SIZE TOTAL_SIZE from v$datafile a,v$tablespace b where a.GROUP_ID=b.id and name not in (‘ROLL’,‘SYSTEM’,‘TEMP’))
loop
v_block_used := 0;
v_block_free := 0;
v_block_alloc := 0;
v_tsname := f.name;
v_tsid := f.ts_id;
v_fileid := f.file_id;
v_total := f.total_size;
v_myrec.block_total = v_total;
mydesc_addr_arr := “SYS”.“DBMS_SPACE”.“EXTENT_XDESC_PAGE_NO_GET”(v_tsid,v_fileid);
for x in (select TS_ID,FILE_ID,PAGE_NO PAGE_NO from array mydesc_addr_arr)
loop
v_full_used :=0;
v_full_free :=0;
v_pageid := x.PAGE_NO;
DBMS_PAGE.PAGE_LOAD(x.TS_ID, x.FILE_ID, x.PAGE_NO, PAGE);
mydesc_item_arr := DBMS_PAGE.SPAGE_ALL_DESC_GET(PAGE);
select count()dbms_space.extent_size_get() into v_full_used from array mydesc_item_arr where state in (1201,1202,1204);
select count()dbms_space.extent_size_get() into v_full_free from array mydesc_item_arr where state=1203 and segid=0;
select count()dbms_space.extent_size_get() into v_alloc from array mydesc_item_arr;
v_myrec.tsid = v_tsid;
v_myrec.fileid = v_fileid;
v_myrec.pageid = v_pageid;
v_myrec.block_used := v_full_used ;
v_myrec.block_free := v_full_free;
v_myrec.block_alloc := v_alloc;
myarr[v_rowno] = v_myrec;
v_rowno := v_rowno +1;
end loop;
end loop;
select tbs_name “名称”,tbs_type “类型”,tbs_status “状态”,
to_char(fsize_mb) “表空间(MB)”,
–to_char(asize_mb) “分配空间(MB)”,
to_char(free_mb) “空闲空间(MB)”,
to_char(used_pct) “使用率(%)”
from
(select
b.name AS tbs_name,
CASE b.TYPE$ WHEN ‘1’ THEN ‘数据’ WHEN ‘2’ THEN ‘临时’ END AS tbs_type,
CASE b.STATUS$ WHEN ‘0’ THEN ‘联机’ WHEN ‘2’ THEN ‘脱机’ WHEN ‘3’ THEN ‘还原’ WHEN ‘4’ THEN ‘损坏’ END AS tbs_status,
round(TBS_BLOCK_TOTAL/1024.0/1024.0page(),2) AS fsize_mb,
–round(TBS_BLOCK_ALLOC/1024.0/1024.0page(),2) AS asize_mb,
round((TBS_BLOCK_TOTAL-TBS_BLOCK_ALLOC+TBS_BLOCK_FREE)/1024.0/1024.0page(),2) AS free_mb,
round((TBS_BLOCK_ALLOC - TBS_BLOCK_FREE)100.0/TBS_BLOCK_TOTAL,2) AS used_pct
from
(
select TSID,
SUM(BLOCK_USED) TBS_BLOCK_USED,
SUM(BLOCK_FREE) TBS_BLOCK_FREE,
SUM(BLOCK_ALLOC) TBS_BLOCK_ALLOC,
SUM(BLOCK_TOTAL) TBS_BLOCK_TOTAL
from
(select TSID,
SUM(BLOCK_USED) BLOCK_USED,
SUM(BLOCK_FREE) BLOCK_FREE,
SUM(BLOCK_ALLOC) BLOCK_ALLOC,
MAX(BLOCK_TOTAL) BLOCK_TOTAL
from array myarr
group by TSID,FILEID)
group by TSID) a,v$tablespace b
where a.TSID=B.ID
and b.name not in (‘SYSTEM’,‘ROLL’,‘TEMP’)
union all
select
name AS tbs_name,
CASE TYPE$ WHEN ‘1’ THEN ‘数据’ WHEN ‘2’ THEN ‘临时’ END AS tbs_type,
CASE STATUS$ WHEN ‘0’ THEN ‘联机’ WHEN ‘2’ THEN ‘脱机’ WHEN ‘3’ THEN ‘还原’ WHEN ‘4’ THEN ‘损坏’ END AS tbs_status,
round(total_size/1024.0/1024.0page(),2) AS fsize_mb,
–round(total_size/1024.0/1024.0page(),2) AS asize_mb,
round((total_size-used_size)/1024.0/1024.0page(),2) AS free_mb,
round(used_size100.0/total_size,2) AS used_pct
from v$tablespace where name in (‘SYSTEM’,‘ROLL’,‘TEMP’)) order by used_pct desc;
end;
datafile空间查询
declare
v_xdesno bigint;
v_rowno bigint;
type myrec_t is record(tsid int,fileid int,pageid bigint,block_used bigint,block_free bigint,block_alloc bigint,block_total bigint);
type myarr_t is array myrec_t[];
myarr myarr_t;
PAGE VARBINARY;
v_tsname varchar(100);
v_tsid int;
v_fileid int;
v_pageid bigint;
v_block_used int;
v_block_free int;
v_block_alloc int;
v_full_used bigint;
v_full_free bigint;
v_alloc bigint;
v_total bigint;
mydesc_addr_arr dbms_space.page_addr_arr_t;
mydesc_item_arr dbms_page.desc_item_arr_t;
v_myrec myrec_t;
begin
v_rowno := 1;
select sum(decode(total_size/DBMS_SPACE.PAGE_N_GET(),0,1,total_size/DBMS_SPACE.PAGE_N_GET())) into v_xdesno from v$datafile;
print v_xdesno;
myarr = new myrec_t[v_xdesno];
for f in (select NAME,GROUP_ID TS_ID,a.ID FILE_ID,a.TOTAL_SIZE TOTAL_SIZE from v$datafile a,v$tablespace b where a.GROUP_ID=b.id and name not in (‘ROLL’,‘SYSTEM’,‘TEMP’))
loop
v_block_used := 0;
v_block_free := 0;
v_block_alloc := 0;
v_tsname := f.name;
v_tsid := f.ts_id;
v_fileid := f.file_id;
v_total := f.total_size;
v_myrec.block_total = v_total;
mydesc_addr_arr := “SYS”.“DBMS_SPACE”.“EXTENT_XDESC_PAGE_NO_GET”(v_tsid,v_fileid);
for x in (select TS_ID,FILE_ID,PAGE_NO PAGE_NO from array mydesc_addr_arr)
loop
v_full_used :=0;
v_full_free :=0;
v_pageid := x.PAGE_NO;
DBMS_PAGE.PAGE_LOAD(x.TS_ID, x.FILE_ID, x.PAGE_NO, PAGE);
mydesc_item_arr := DBMS_PAGE.SPAGE_ALL_DESC_GET(PAGE);
select count()dbms_space.extent_size_get() into v_full_used from array mydesc_item_arr where state in (1201,1202,1204);
select count()dbms_space.extent_size_get() into v_full_free from array mydesc_item_arr where state=1203 and segid=0;
select count()dbms_space.extent_size_get() into v_alloc from array mydesc_item_arr;
v_myrec.tsid = v_tsid;
v_myrec.fileid = v_fileid;
v_myrec.pageid = v_pageid;
v_myrec.block_used := v_full_used ;
v_myrec.block_free := v_full_free;
v_myrec.block_alloc := v_alloc;
myarr[v_rowno] = v_myrec;
v_rowno := v_rowno +1;
end loop;
end loop;
SELECT
B.PATH AS “文件路径”,
TO_CHAR(ROUND(A.BLOCK_TOTAL/1024.0/1024.0PAGE(),2)) AS “文件大小(MB)”,
–TO_CHAR(ROUND(A.BLOCK_ALLOC/1024.0/1024.0PAGE(),2)) AS “分配大小(MB)”,
TO_CHAR(ROUND((A.BLOCK_TOTAL-A.BLOCK_ALLOC+A.BLOCK_FREE)/1024.0/1024.0PAGE(),2)) AS “空闲大小(MB)”,
TO_CHAR(ROUND(A.BLOCK_USED100.0/A.BLOCK_TOTAL,2)) AS “使用率(%)”,
CASE AUTO_EXTEND WHEN ‘0’ THEN ‘否’ WHEN ‘1’ THEN ‘是’ END AS “自动扩展”,
NEXT_SIZE AS “扩展尺寸(MB)”,
to_char(MAX_SIZE) AS “扩展上限(MB)”
from
(select TSID,FILEID,
SUM(BLOCK_USED) BLOCK_USED,
SUM(BLOCK_FREE) BLOCK_FREE,
SUM(BLOCK_ALLOC) BLOCK_ALLOC,
MAX(BLOCK_TOTAL) BLOCK_TOTAL
from array myarr
group by TSID,FILEID
) a,v$datafile b
where a.TSID=B.GROUP_ID
AND A.FILEID=B.ID
union all
SELECT PATH AS “文件路径”,
TO_CHAR(ROUND(a.TOTAL_SIZE/1024.0/1024.0PAGE(),2)) AS “文件大小(MB)”,
–TO_CHAR(ROUND(a.TOTAL_SIZE/1024.0/1024.0PAGE(),2)) AS “分配大小(MB)”,
TO_CHAR(ROUND(a.FREE_SIZE/1024.0/1024.0PAGE(),2)) AS “空闲大小(MB)”,
(TO_CHAR(ROUND(100-a.FREE_SIZE100/a.TOTAL_SIZE,2))) AS “使用率(%)”,
CASE AUTO_EXTEND WHEN ‘0’ THEN ‘否’ WHEN ‘1’ THEN ‘是’ END AS “自动扩展”,
NEXT_SIZE AS “扩展尺寸(MB)”,
to_char(a.MAX_SIZE) AS “扩展上限(MB)”
FROM v$datafile a,v$tablespace b where a.GROUP_ID=b.id and name in (‘ROLL’,‘SYSTEM’,‘TEMP’);
end;
next 参数是自动扩展的步长,您在创建表空间时,设置为0。没办法扩展。
修改一下next 改为非0的整数。