查询oracle数据块的使用情况(procedure)
create or replace procedure space_of_use(v_segment_owner in varchar2 default user,v_segment_name in varchar2,v_segment_type varchar2 default 'TABLE')
as
--空闲介于0%-25%之间的块数
fs1_blocks number;
fs1_bytes number;
--空闲介于25%-50%之间的块数
fs2_blocks number;
fs2_bytes number;
--空闲介于50%-75%之间的块数
fs3_blocks number;
fs3_bytes number;
--空闲介于75%-100%之间的块数
fs4_blocks number;
fs4_bytes number;
--全部填满的块数
full_blocks number;
full_bytes number;
--未格式化的块数
noformatted_blocks number;
noformatted_bytes number;
begin
dbms_space.space_usage(
segment_owner => v_segment_owner,
segment_name => v_segment_name,
segment_type => v_segment_type,
fs1_bytes => fs1_bytes,
fs1_blocks => fs1_blocks,
fs2_bytes => fs2_bytes,
fs2_blocks=>fs2_blocks,
fs3_bytes => fs3_bytes,
fs3_blocks => fs3_blocks,
fs4_bytes => fs4_bytes,
fs4_blocks => fs4_blocks,
full_bytes => full_bytes,
full_blocks => full_blocks,
unformatted_blocks => noformatted_blocks,
unformatted_bytes => noformatted_bytes
);
dbms_output.put_line('未格式化的块数 '||noformatted_blocks);
dbms_output.put_line('0%-25%之间的块数 '||fs1_blocks);
dbms_output.put_line('25%-50%之间的块数 '||fs2_blocks);
dbms_output.put_line('50%-75%之间的块数 '||fs3_blocks);
dbms_output.put_line('75%-100%之间的块数 '||fs4_blocks);
dbms_output.put_line('全部填满的块数 '||full_blocks);
end;