热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

oracle工具:show_space简介

oracle工具:show_space简介createorreplaceprocedureshow_space(p_segname_1invarchar2,p_spaceinvarchar2default'MANUAL',p_type_1invarchar2default&#39

oracle工具:show_space简介
 
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); 
  www.2cto.com  
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; 
 
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 = &#39;MANUAL&#39; or (p_space <> &#39;auto&#39; and p_space <> &#39;AUTO&#39;) 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( &#39;Free Blocks&#39;, l_free_blks ); 
end if; 
 
p( &#39;Total Blocks&#39;, l_total_blocks ); 
p( &#39;Total Bytes&#39;, l_total_bytes ); 
p( &#39;Unused Blocks&#39;, l_unused_blocks ); 
p( &#39;Unused Bytes&#39;, l_unused_bytes ); 
p( &#39;Last Used Ext FileId&#39;, l_LastUsedExtFileId ); 
p( &#39;Last Used Ext BlockId&#39;, l_LastUsedExtBlockId ); 
p( &#39;Last Used Block&#39;, l_LAST_USED_BLOCK ); 
 
/*IF the segment is analyzed */ 
if p_analyzed = &#39;Y&#39; 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(&#39; &#39;,50,&#39;*&#39;)); 
dbms_output.put_line(&#39;The segment is analyzed&#39;); 
p( &#39;0% -- 25% free space blocks&#39;, l_fs1_blocks); 
p( &#39;0% -- 25% free space bytes&#39;, l_fs1_bytes); 
p( &#39;25% -- 50% free space blocks&#39;, l_fs2_blocks); 
p( &#39;25% -- 50% free space bytes&#39;, l_fs2_bytes); 
p( &#39;50% -- 75% free space blocks&#39;, l_fs3_blocks); 
p( &#39;50% -- 75% free space bytes&#39;, l_fs3_bytes); 
p( &#39;75% -- 100% free space blocks&#39;, l_fs4_blocks); 
p( &#39;75% -- 100% free space bytes&#39;, l_fs4_bytes); 
p( &#39;Unused Blocks&#39;, l_unformatted_blocks ); 
p( &#39;Unused Bytes&#39;, l_unformatted_bytes ); 
p( &#39;Total Blocks&#39;, l_full_blocks); 
p( &#39;Total bytes&#39;, l_full_bytes); 
 
end if; 
 
end; 
 
ASSM 类型的 表 
 
SQL> exec show_space(&#39;t&#39;,&#39;auto&#39;); 
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. 
  www.2cto.com  
ASSM 类型的索引 
 
SQL> exec show_space(&#39;t_index&#39;,&#39;auto&#39;,&#39;i&#39;); 
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. 
  www.2cto.com  
对analyze 过的segment 可以这样 
 
SQL> exec show_space(&#39;t&#39;,&#39;auto&#39;,&#39;T&#39;,&#39;Y&#39;); 
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.
 

推荐阅读
  • 本文详细介绍如何使用Python进行配置文件的读写操作,涵盖常见的配置文件格式(如INI、JSON、TOML和YAML),并提供具体的代码示例。 ... [详细]
  • 1:有如下一段程序:packagea.b.c;publicclassTest{privatestaticinti0;publicintgetNext(){return ... [详细]
  • 本文探讨了适用于Spring Boot应用程序的Web版SQL管理工具,这些工具不仅支持H2数据库,还能够处理MySQL和Oracle等主流数据库的表结构修改。 ... [详细]
  • 本文详细介绍了如何通过多种编程语言(如PHP、JSP)实现网站与MySQL数据库的连接,包括创建数据库、表的基本操作,以及数据的读取和写入方法。 ... [详细]
  • 在当前众多持久层框架中,MyBatis(前身为iBatis)凭借其轻量级、易用性和对SQL的直接支持,成为许多开发者的首选。本文将详细探讨MyBatis的核心概念、设计理念及其优势。 ... [详细]
  • 在使用 DataGridView 时,如果在当前单元格中输入内容但光标未移开,点击保存按钮后,输入的内容可能无法保存。只有当光标离开单元格后,才能成功保存数据。本文将探讨如何通过调用 DataGridView 的内置方法解决此问题。 ... [详细]
  • 本文详细介绍了如何在 Linux 平台上安装和配置 PostgreSQL 数据库。通过访问官方资源并遵循特定的操作步骤,用户可以在不同发行版(如 Ubuntu 和 Red Hat)上顺利完成 PostgreSQL 的安装。 ... [详细]
  • 如何在PostgreSQL中查看数据表
    本文将指导您使用pgAdmin工具连接到PostgreSQL数据库,并展示如何浏览和查找其中的数据表。通过简单的步骤,您可以轻松访问所需的表结构和数据。 ... [详细]
  • 利用存储过程构建年度日历表的详细指南
    本文将介绍如何使用SQL存储过程创建一个完整的年度日历表。通过实例演示,帮助读者掌握存储过程的应用技巧,并提供详细的代码解析和执行步骤。 ... [详细]
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • 在使用SQL Server进行动态SQL查询时,如果遇到LIKE语句无法正确返回预期结果的情况,通常是因为参数传递方式不当。本文将详细探讨这一问题,并提供解决方案及相关的技术背景。 ... [详细]
  • 本文介绍如何通过创建替代插入触发器,使对视图的插入操作能够正确更新相关的基本表。涉及的表包括:飞机(Aircraft)、员工(Employee)和认证(Certification)。 ... [详细]
  • MySQL缓存机制深度解析
    本文详细探讨了MySQL的缓存机制,包括主从复制、读写分离以及缓存同步策略等内容。通过理解这些概念和技术,读者可以更好地优化数据库性能。 ... [详细]
  • SQLite 动态创建多个表的需求在网络上有不少讨论,但很少有详细的解决方案。本文将介绍如何在 Qt 环境中使用 QString 类轻松实现 SQLite 表的动态创建,并提供详细的步骤和示例代码。 ... [详细]
  • 精选30本C# ASP.NET SQL中文PDF电子书合集
    欢迎订阅我们的技术博客,获取更多关于C#、ASP.NET和SQL的最新资讯和资源。 ... [详细]
author-avatar
小梅LMY
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有