show_space改良版,增加表分区索引分区自动识别
发表于:2025-01-21 作者:千家信息网编辑
千家信息网最后更新 2025年01月21日,new_show_space.sql.zipREMREM based on previous show_space script, now it can REM identify all pa
千家信息网最后更新 2025年01月21日show_space改良版,增加表分区索引分区自动识别
new_show_space.sql.zip
REMREM based on previous show_space script, now it can REM identify all partition_name for table or index-REM automatically without specifying partition_name.REMREM Usage:REM exec show_space('TABLE','OWNER','TABLE_NAME');REM orREM exec show_space('TABLE PARTITION','TEST','P_TAB','PART1');REMREM exec show_space('INDEX','TEST','IDX_TAB');REM orREM exec show_space('INDEX PARTITION','TEST','IDX_TAB','IDX_PART1');REMREM Edited by mx at 2020/03/27REM -- based on previous procedure show_space from Internet.set serveroutput onCREATE OR REPLACE PROCEDURE show_space ( v_segment_type IN VARCHAR2 DEFAULT 'TABLE', v_segment_owner IN VARCHAR2 DEFAULT USER, v_segment_name IN VARCHAR2, v_partition_name IN VARCHAR2 DEFAULT NULL, v_space IN VARCHAR2 DEFAULT 'AUTO', v_analyzed IN VARCHAR2 DEFAULT 'Y' ) AS p_segment_type VARCHAR2 ( 30 );p_segment_owner VARCHAR2 ( 30 );p_segment_name VARCHAR2 ( 50 );p_partition_name VARCHAR2 ( 30 );p_partitioned VARCHAR2 ( 5 );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 print ( p_label IN VARCHAR2, p_num IN NUMBER ) IS BEGIN dbms_output.put_line ( rpad( p_label, 40, '.' ) || p_num ); END;PROCEDURE analyze_space ( f_segment_type IN VARCHAR2, f_segment_owner IN VARCHAR2, f_segment_name IN VARCHAR2, f_partition_name IN VARCHAR2 ) IS BEGIN dbms_space.unused_space ( segment_owner => f_segment_owner, segment_name => f_segment_name, segment_type => f_segment_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, partition_name => f_partition_name ); IF v_space = 'MANUAL' OR ( v_space <> 'auto' AND v_space <> 'AUTO' ) THEN dbms_space.free_blocks ( segment_owner => f_segment_owner, segment_name => f_segment_name, segment_type => f_segment_type, freelist_group_id => 0, free_blks => l_free_blks, partition_name => f_partition_name ); print ( 'Free Blocks', l_free_blks ); END IF; IF ( f_partition_name IS NULL ) THEN dbms_output.put_line ( '--' || rpad( f_segment_owner || '.' || f_segment_name, 45, '-' ) ); ELSE dbms_output.put_line ( '--' || rpad( f_segment_owner || '.' || f_segment_name || '.' || f_partition_name, 45, '-' ) ); END IF; print ( 'Total Blocks', l_total_blocks ); print ( 'Total Bytes', l_total_bytes ); print ( 'Unused Blocks', l_unused_blocks ); print ( 'Unused Bytes', l_unused_bytes ); print ( 'Last Used Ext FileId', l_LastUsedExtFileId ); print ( 'Last Used Ext BlockId', l_LastUsedExtBlockId ); print ( 'Last Used Block', l_LAST_USED_BLOCK );/*IF the segment is analyzed */ IF v_analyzed = 'Y' THEN dbms_space.space_usage ( segment_owner => f_segment_owner, segment_name => f_segment_name, segment_type => f_segment_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, partition_name => f_partition_name ); dbms_output.put_line ( 'The segment is analyzed.' ); print ( '0% -- 25% free space blocks', l_fs1_blocks ); print ( '0% -- 25% free space bytes', l_fs1_bytes ); print ( '25% -- 50% free space blocks', l_fs2_blocks ); print ( '25% -- 50% free space bytes', l_fs2_bytes ); print ( '50% -- 75% free space blocks', l_fs3_blocks ); print ( '50% -- 75% free space bytes', l_fs3_bytes ); print ( '75% -- 100% free space blocks', l_fs4_blocks ); print ( '75% -- 100% free space bytes', l_fs4_bytes ); print ( 'Unused Blocks', l_unformatted_blocks ); print ( 'Unused Bytes', l_unformatted_bytes ); print ( 'Total Blocks', l_full_blocks ); print ( 'Total bytes', l_full_bytes ); dbms_output.put_line ( rpad( ' ', 48, '-' ) ); END IF; END;BEGIN p_segment_name := upper( v_segment_name ); p_segment_owner := upper( v_segment_owner ); p_segment_type := upper( v_segment_type ); p_partition_name := upper( v_partition_name );IF ( v_segment_type = 'i' OR v_segment_type = 'I' ) THEN p_segment_type := 'INDEX'; END IF; IF ( v_segment_type = 't' OR v_segment_type = 'T' ) THEN p_segment_type := 'TABLE'; END IF; IF ( v_segment_type = 'c' OR v_segment_type = 'C' ) THEN p_segment_type := 'CLUSTER'; END IF; SELECT partitioned INTO p_partitioned FROM ( SELECT partitioned FROM all_tables WHERE owner = p_segment_owner AND table_name = p_segment_name UNION SELECT partitioned FROM all_indexes WHERE owner = p_segment_owner AND index_name = p_segment_name ); IF ( p_segment_type = 'TABLE' AND p_partitioned = 'YES' ) THEN p_segment_type := 'TABLE PARTITION'; FOR t IN ( SELECT partition_name FROM all_tab_partitions WHERE table_owner = p_segment_owner AND table_name = p_segment_name ORDER BY to_number( regexp_substr( partition_name, '[0-9]*[0-9]', 1 ) ) ) loop analyze_space ( p_segment_type, p_segment_owner, p_segment_name, t.partition_name ); END loop;ELSIF ( p_segment_type = 'INDEX' AND p_partitioned = 'YES' ) THEN p_segment_type := 'INDEX PARTITION'; FOR i IN ( SELECT partition_name FROM all_tab_partitions WHERE table_owner = p_segment_owner AND table_name = p_segment_name ORDER BY to_number( regexp_substr( partition_name, '[0-9]*[0-9]', 1 ) ) ) loop analyze_space ( p_segment_type, p_segment_owner, p_segment_name, i.partition_name ); END loop;ELSE analyze_space ( p_segment_type, p_segment_owner, p_segment_name, p_partition_name );END IF;EXCEPTION WHEN others THEN dbms_output.put_line('Usage:'); dbms_output.put_line('- exec show_space(''table'',''owner'',''table_name'');'); dbms_output.put_line('- exec show_space(''table partition'',''owner'',''table_name'',''partition_name'');'); dbms_output.put_line('- exec show_space(''index'',''owner'',''index_name'');'); dbms_output.put_line('- exec show_space(''index partition'',''owner'',''index_name'',''partition_name'');');END;/
索引
自动识别
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
咸宁计算机软件开发管理
哪有软件开发定制
软件开发前沿的技术
p2p网络技术如何实现
株洲互联网软件开发工程师
网络安全概述
网络安全基础设施风险评估
普陀区银联数据库收费标准
从事软件开发考证
bim服务器在哪里安装
赛尔网络技术面过了
河南项目软件开发价格表
选择服务器 高级
原始数据库一定要存放在()下
怎么知道发票开票软件服务器维护
生死狙击其他服务器活动
廊坊众搜网络技术有限公司
南方网网络技术开发
软件开发中迭代法是什么
网络安全js选择题
华为最好的服务器硬盘
服务器同步代码
数据库管理系统第三版
数据库防伪技术管理制度
常熟网络技术咨询费用
华为服务器价格
网吧服务器不自动重启
数据库表加索引与不加索引
海康v4200数据库考勤记录
中国化学历史教交易数据库