`
wsql
  • 浏览: 11809183 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

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);

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 = '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' 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 类型的 表

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.
分享到:
评论

相关推荐

    Oracle8i_9i数据库基础

    §2.5.11 SHOW ALL(列出所有参数) 85 §2.6 格式化输出 87 §2.6.1 一般数据的格式化输出 87 §2.6.2 日期的格式化输出 88 §2.7 加标题 89 §2.8 建立简单报告 90 §2.9 输入变量 91 第三章 表及索引的定义操作 94 ...

    Oracle 10gR2压缩(Compress)技术

    Oracle 10gR2压缩(Compress)技术 1 1、oracle压缩简介 1 2、oracle压缩优点 2 3、压缩分类 2 3.1 表级压缩 2 3.2 表空间级压缩 3 ...附录A、show_space存储过程查看段使用情况 19 附录B、Oracle11gR2 Compress 21

    ora分析脚本

    - asm: Show asm space/free space - space []: view used/free space in a given tbs - binds &lt;sql_id&gt; : display bind capture information for specified cursor - fulltext &lt;sql_id&gt; : display the entire ...

    oracle函数大全.doc

    ORACLE函数大全 ________________________________________ 作者:[本站编辑] 来源:[CSDN] 浏览:[ ] SQL中的单记录函数 1.ASCII 返回与指定的字符对应的十进制数; SQL&gt; select ascii('A') A,ascii('a') a,...

    Oracle事例

    alter table TABLE_NAME add constraint KEY_NAME primary key (TABLE_COLUMN) using index tablespace TABLE_SPACE_NAME; 2.增加外键 alter table TABLE_NAME add constraint FK_NAME foreign key (TABLE_COLUMN)...

    DB_monitor.rar

    show parameter utl alter system set utl_file_dir='d:\temp\a' scope=spfile; 安装 sqlplus /nolog conn /as sysdba @?/rdbms/admin/dbmslm.sql @?/rdbms/admin/dbmslmd.sql 使用LogMiner工具 9i: ...

    MYSQL,SQLSERVER,ORACLE常用的函数

    SQL&gt; select instr('oracle traning','ra',1,2) instring from dual; INSTRING --------- 9 6.LENGTH 返回字符串的长度; SQL&gt; select name,length(name),addr,length(addr),sal,length(to_char(sal)) from ....

    oracle DBA日常脚本

    ..........\Show_Space.sql ..........\Source.sql ..........\SQL_Area.sql ..........\SQL_Text.sql ..........\System_Parameters.sql ..........\Table_Dep.sql ..........\Table_Extents.sql ............

    Oracle编程艺术

    SHOW_SPACE ............................................................................. 49 BIG_TABLE ................................................................................. 57 代码约定........

    php.ini-development

    Whitespace and lines ; beginning with a semicolon are silently ignored (as you probably guessed). ; Section headers (e.g. [Foo]) are also silently ignored, even though ; they might mean something in ...

    解决Oracle数据库归档日志占满磁盘空间问题

    1、常用命令 SQL&gt; show parameter log_archive_dest;...SQL&gt; select sum(percent_space_used)*3/100 from v$flash_recovery_area_usage; 2.9904 SQL&gt; show parameter recover; db_recovery_file_dest

    数据库基础 ORACLE

    §2.5.11 SHOW ALL(列出所有参数) 85 §2.6 格式化输出 87 §2.6.1 一般数据的格式化输出 87 §2.6.2 日期的格式化输出 88 §2.7 加标题 90 §2.8 建立简单报告 90 §2.9 输入变量 92 第三章 表及索引的定义操作 94 ...

    Toad 使用快速入门

    Quest Software为此提供了高效的Oracle应用开发工具-Toad(Tools of Oracle Application Developers)。在Toad的新版本中,还加入了DBA模块,可以帮助DBA完成许多日常管理工作。它最大的特点就是简单易用,访问速度...

    (重要)AIX command 使用总结.txt

    AIX常用命令://查看机器序列号,IBM的基本信息都可以通过该命令查询得到 #prtconf #oslevel -r == uname -a //操作系统版本 #oslevel //查看操作系统版本ex :5.1.0.0 #oslevel -r //ex:5100-04 == oslevel -q ...

    plsqldev14.0.0.1961x32多语言版+sn.rar

    The new viewer allows you to ignore differences in case and white space as usual, but it can also ignore differences in comments. Program Window enhancements The Program Window now highlights ...

    plsqldev14.0.0.1961x64多语言版+sn.rar

    64位版本的 PLSQL 正式版,只能运行在64位系统中,需要你安装 64 位的 Oracle 客户端。 安装请查看说明。 APRIL 17, 2020 - VERSION 14.0 RELEASED Built-in Version Control support for Git and Subversion ...

    MS-DOS 5.0

    README.TXT NOTES ON MS-DOS VERSION 5.0 =========================== In this file the following topics are covered: 1. Introduction 2. Solving Setup Problems 2.1 Priam and Everex Hard Disks ...

    数据库基础

    §2.5.11 SHOW ALL(列出所有参数) 85 §2.6 格式化输出 87 §2.6.1 一般数据的格式化输出 87 §2.6.2 日期的格式化输出 88 §2.7 加标题 89 §2.8 建立简单报告 90 §2.9 输入变量 91 第三章 表及索引的定义操作 94 ...

    SQL Assistant v5.0

    "Show Keys and Indexed Columns" is preset for all assistance types by default. Primary keys, foreign keys, and indexed columns are displayed by default in column popups and mouse-over hints. Mouse-...

Global site tag (gtag.js) - Google Analytics