转载 show_space

     tom提供的show_space,有一些限制,主要是不能应用于assm环境。下面提供一些改进的

ITPUB上提供了该工具的很多版本,具体还有以下几个版本,也很好用,对今后的工具大有好处!

xzh2000 提供的最终混合超级完全无敌版:

 

SQL代码
  1. create or replace procedure show_space    
  2. ( p_segname_1 in varchar2,    
  3. p_space in varchar2 default 'MANUAL',    
  4. p_type_1 in varchar2 default 'TABLE' ,    
  5. p_analyzed in varchar2 default 'N',    
  6. p_owner_1 in varchar2 default user)    
  7. as    
  8. p_segname varchar2(100);    
  9. p_type varchar2(10);    
  10. p_owner varchar2(30);    
  11.   
  12. l_unformatted_blocks number;    
  13. l_unformatted_bytes number;    
  14. l_fs1_blocks number;    
  15. l_fs1_bytes number;    
  16. l_fs2_blocks number;    
  17. l_fs2_bytes number;    
  18. l_fs3_blocks number;    
  19. l_fs3_bytes number;    
  20. l_fs4_blocks number;    
  21. l_fs4_bytes number;    
  22. l_full_blocks number;    
  23. l_full_bytes number;    
  24.   
  25. l_free_blks number;    
  26. l_total_blocks number;    
  27. l_total_bytes number;    
  28. l_unused_blocks number;    
  29. l_unused_bytes number;    
  30. l_LastUsedExtFileId number;    
  31. l_LastUsedExtBlockId number;    
  32. l_LAST_USED_BLOCK number;    
  33.   
  34. procedure p( p_label in varchar2, p_num in number )    
  35. is    
  36. begin    
  37. dbms_output.put_line( rpad(p_label,40,'.') ||    
  38. p_num );    
  39. end;    
  40. begin    
  41. p_segname := upper(p_segname_1); -- rainy changed    
  42. p_owner := upper(p_owner_1);    
  43. p_type := p_type_1;    
  44.   
  45. if (p_type_1 = 'i' or p_type_1 = 'I'then --rainy changed    
  46. p_type := 'INDEX';    
  47. end if;    
  48.   
  49. if (p_type_1 = 't' or p_type_1 = 'T'then --rainy changed    
  50. p_type := 'TABLE';    
  51. end if;    
  52.   
  53. if (p_type_1 = 'c' or p_type_1 = 'C'then --rainy changed    
  54. p_type := 'CLUSTER';    
  55. end if;    
  56.   
  57.   
  58. dbms_space.unused_space    
  59. ( segment_owner => p_owner,    
  60. segment_name => p_segname,    
  61. segment_type => p_type,    
  62. total_blocks => l_total_blocks,    
  63. total_bytes => l_total_bytes,    
  64. unused_blocks => l_unused_blocks,    
  65. unused_bytes => l_unused_bytes,    
  66. LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,    
  67. LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,    
  68. LAST_USED_BLOCK => l_LAST_USED_BLOCK );    
  69.   
  70. if p_space = 'MANUAL' or (p_space <> 'auto' and p_space <> 'AUTO'then    
  71. dbms_space.free_blocks    
  72. ( segment_owner => p_owner,    
  73. segment_name => p_segname,    
  74. segment_type => p_type,    
  75. freelist_group_id => 0,    
  76. free_blks => l_free_blks );    
  77.   
  78. p( 'Free Blocks', l_free_blks );    
  79. end if;    
  80.   
  81. p( 'Total Blocks', l_total_blocks );    
  82. p( 'Total Bytes', l_total_bytes );    
  83. p( 'Unused Blocks', l_unused_blocks );    
  84. p( 'Unused Bytes', l_unused_bytes );    
  85. p( 'Last Used Ext FileId', l_LastUsedExtFileId );    
  86. p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );    
  87. p( 'Last Used Block', l_LAST_USED_BLOCK );    
  88.   
  89.   
  90. /*IF the segment is analyzed */    
  91. if p_analyzed = 'Y' then    
  92. dbms_space.space_usage(segment_owner => p_owner ,    
  93. segment_name => p_segname ,    
  94. segment_type => p_type ,    
  95. unformatted_blocks => l_unformatted_blocks ,    
  96. unformatted_bytes => l_unformatted_bytes,    
  97. fs1_blocks => l_fs1_blocks,    
  98. fs1_bytes => l_fs1_bytes ,    
  99. fs2_blocks => l_fs2_blocks,    
  100. fs2_bytes => l_fs2_bytes,    
  101. fs3_blocks => l_fs3_blocks ,    
  102. fs3_bytes => l_fs3_bytes,    
  103. fs4_blocks => l_fs4_blocks,    
  104. fs4_bytes => l_fs4_bytes,    
  105. full_blocks => l_full_blocks,    
  106. full_bytes => l_full_bytes);    
  107. dbms_output.put_line(rpad(' ',50,'*'));    
  108. dbms_output.put_line('The segment is analyzed');    
  109. p( '0% -- 25% free space blocks', l_fs1_blocks);    
  110. p( '0% -- 25% free space bytes', l_fs1_bytes);    
  111. p( '25% -- 50% free space blocks', l_fs2_blocks);    
  112. p( '25% -- 50% free space bytes', l_fs2_bytes);    
  113. p( '50% -- 75% free space blocks', l_fs3_blocks);    
  114. p( '50% -- 75% free space bytes', l_fs3_bytes);    
  115. p( '75% -- 100% free space blocks', l_fs4_blocks);    
  116. p( '75% -- 100% free space bytes', l_fs4_bytes);    
  117. p( 'Unused Blocks', l_unformatted_blocks );    
  118. p( 'Unused Bytes', l_unformatted_bytes );    
  119. p( 'Total Blocks', l_full_blocks);    
  120. p( 'Total bytes', l_full_bytes);    
  121.   
  122. end if;    
  123.   
  124. end;   
  125.   
  126. /   
  127.   




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.
 

 



Link URL: http://www.csjrc.com/default.asp?id=90

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/89703/viewspace-217909/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/89703/viewspace-217909/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值