Oracle查看段信息show_space()
来源:互联网 发布:网络视频下载神器 编辑:程序博客网 时间:2024/06/14 09:19
/**
查看段信息的存储过程show_space()
此版主要查看当前用户下的信息。
如果要察看其他用户信息需要修改
这里
select t.segment_space_management into p_space
from user_tablespaces t , user_segments s
where s.tablespace_name = t.tablespace_name
and segment_name = p_segname
--and s.owner = p_owner
and s.segment_type = p_type ;
为
select t.segment_space_management into p_space
from dba_tablespaces t , dba_segments s
where s.tablespace_name = t.tablespace_name
and segment_name = p_segname
and s.owner = p_owner
and s.segment_type = p_type ;
并赋予current_user 查询dba_tablespace,dba_segments 权限
grant select on dba_tablespace,dba_segments to current_user
*/
create or replace procedure show_space
( p_segname_1 in varchar2,
--p_space in varchar2 default 'MANUAL',
p_type_1 in varchar2 default 'TABLE' ,
p_analyzed in varchar2 default 'N',
p_owner_1 in varchar2 default user)
AS
p_segname varchar2(100);
p_type varchar2(10);
p_owner varchar2(30);
p_space varchar2(10);
l_unformatted_blocks number;
l_unformatted_bytes number;
l_fs1_blocks number;
l_fs1_bytes number;
l_fs2_blocks number;
l_fs2_bytes number;
l_fs3_blocks number;
l_fs3_bytes number;
l_fs4_blocks number;
l_fs4_bytes number;
l_full_blocks number;
l_full_bytes number;
l_free_blks number;
l_total_blocks number;
l_total_bytes number;
l_unused_blocks number;
l_unused_bytes number;
l_LastUsedExtFileId number;
l_LastUsedExtBlockId number;
l_LAST_USED_BLOCK number;
procedure p( p_label in varchar2, p_num in number )
is
begin
dbms_output.put_line( rpad(p_label,40,'.') ||
p_num );
end;
begin
p_segname := upper(p_segname_1); -- rainy changed
p_owner := upper(p_owner_1);
p_type := p_type_1;
if (p_type_1 = 'i' or p_type_1 = 'I') then --rainy changed
p_type := 'INDEX';
end if;
if (p_type_1 = 't' or p_type_1 = 'T') then --rainy changed
p_type := 'TABLE';
end if;
if (p_type_1 = 'c' or p_type_1 = 'C') then --rainy changed
p_type := 'CLUSTER';
end if;
select t.segment_space_management into p_space
from user_tablespaces t , user_segments s
where s.tablespace_name = t.tablespace_name
and segment_name = p_segname
--and s.owner = p_owner
and s.segment_type = p_type ;
dbms_space.unused_space
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
total_blocks => l_total_blocks,
total_bytes => l_total_bytes,
unused_blocks => l_unused_blocks,
unused_bytes => l_unused_bytes,
LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
LAST_USED_BLOCK => l_LAST_USED_BLOCK );
if p_space = 'MANUAL' or (p_space <> 'auto' and p_space <> 'AUTO') then
dbms_space.free_blocks
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
freelist_group_id => 0,
free_blks => l_free_blks );
p( 'Free Blocks', l_free_blks );
end if;
p( 'Total Blocks', l_total_blocks );
p( 'Total Bytes', l_total_bytes );
p( 'Unused Blocks', l_unused_blocks );
p( 'Unused Bytes', l_unused_bytes );
p( 'Last Used Ext FileId', l_LastUsedExtFileId );
p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
p( 'Last Used Block', l_LAST_USED_BLOCK );
/*IF the segment is analyzed */
if (p_analyzed = 'Y' OR p_space = 'auto' OR p_space = 'AUTO') then
dbms_space.space_usage(segment_owner => p_owner ,
segment_name => p_segname ,
segment_type => p_type ,
unformatted_blocks => l_unformatted_blocks ,
unformatted_bytes => l_unformatted_bytes,
fs1_blocks => l_fs1_blocks,
fs1_bytes => l_fs1_bytes ,
fs2_blocks => l_fs2_blocks,
fs2_bytes => l_fs2_bytes,
fs3_blocks => l_fs3_blocks ,
fs3_bytes => l_fs3_bytes,
fs4_blocks => l_fs4_blocks,
fs4_bytes => l_fs4_bytes,
full_blocks => l_full_blocks,
full_bytes => l_full_bytes);
dbms_output.put_line(rpad(' ',50,'*'));
dbms_output.put_line('The segment is analyzed');
p( '0% -- 25% free space blocks', l_fs1_blocks);
p( '0% -- 25% free space bytes', l_fs1_bytes);
p( '25% -- 50% free space blocks', l_fs2_blocks);
p( '25% -- 50% free space bytes', l_fs2_bytes);
p( '50% -- 75% free space blocks', l_fs3_blocks);
p( '50% -- 75% free space bytes', l_fs3_bytes);
p( '75% -- 100% free space blocks', l_fs4_blocks);
p( '75% -- 100% free space bytes', l_fs4_bytes);
p( 'Unused Blocks', l_unformatted_blocks );
p( 'Unused Bytes', l_unformatted_bytes );
p( 'Total Blocks', l_full_blocks);
p( 'Total bytes', l_full_bytes);
end if;
end;
/*
例 ASSM:自动段空间管理
非ASSM 类型的表:
SQL> exec show_space('t');
ASSM 类型的 表
SQL> exec show_space('t','auto');
Total Blocks............................512
Total Bytes.............................4194304
Unused Blocks...........................78
Unused Bytes............................638976
Last Used Ext FileId....................9
Last Used Ext BlockId...................25608
Last Used Block.........................50
PL/SQL procedure successfully completed.
ASSM 类型的索引
SQL> exec show_space('t_index','auto','i');
Total Blocks............................80
Total Bytes.............................655360
Unused Blocks...........................5
Unused Bytes............................40960
Last Used Ext FileId....................9
Last Used Ext BlockId...................25312
Last Used Block.........................3
PL/SQL procedure successfully completed.
对analyze 过的segment 可以这样
SQL> exec show_space('t','auto','T','Y');
Total Blocks............................512
Total Bytes.............................4194304
Unused Blocks...........................78
Unused Bytes............................638976
Last Used Ext FileId....................9
Last Used Ext BlockId...................25608
Last Used Block.........................50
*************************************************
The segment is analyzed
0% -- 25% free space blocks.............0
0% -- 25% free space bytes..............0
25% -- 50% free space blocks............0
25% -- 50% free space bytes.............0
50% -- 75% free space blocks............0
50% -- 75% free space bytes.............0
75% -- 100% free space blocks...........0
75% -- 100% free space bytes............0
Unused Blocks...........................0
Unused Bytes............................0
Total Blocks............................418
Total bytes.............................3424256
PL/SQL procedure successfully completed.
参考:http://www.itpub.net/viewthread.php?tid=239697
*/
- Oracle查看段信息show_space()
- Oracle查看对象空间使用情况show_space
- Oracle 查看用户表和表字段信息
- oracle工具:show_space
- oracle show_space脚本
- oracle的show_space存储过程
- ORACLE存储过程show_space完整版
- oracle的show_space存储过程
- 查询oracle表字段信息
- SHOW_SPACE
- show_space
- show_space
- SHOW_SPACE
- show_space
- SHOW_SPACE
- show_space
- show_space
- SHOW_SPACE
- C#多线程学习(五) 多线程的自动管理(定时器)
- 什么是成功?
- js入门(三)
- ERP系统模块完全解析──主生产计划MPS
- 什么是序列化
- Oracle查看段信息show_space()
- Openvms QQ群: 主群11112300,副群135272460
- read the code read the soul
- 练习55
- linux下的截图工具
- submit 按钮提交无效 点击无效果 不可用
- ERP项目实施正式开始了
- 上学为了啥?大学生十宗罪
- 关闭子窗口后刷新父窗口