show-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 3502608
  • 博文数量: 718
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7790
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(718)

文章存档

2024年(4)

2023年(74)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

最近访客
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2021-05-07 17:28:24


仅供参考

  1. create or replace procedure show_space(p_segname_1 in varchar2,
  2.                                        p_type_1 in varchar2 default 'table',
  3.                                        p_space in varchar2 default 'auto',
  4.                                        p_analyzed in varchar2 default 'n',
  5.                                        p_partition_1 in varchar2 default null,
  6.                                        p_owner_1 in varchar2 default user)
  7.   authid current_user as
  8.   /*
  9.   -- grant execute on sys.dbms_space to scott;  -- 普通用户
  10.   -- exec dbms_stats.gather_table_stats('scott','emp')  -- 提前收集统计信息
  11.   -- exec show_space('emp', 'table', 'auto', 'y', null, 'scott')
  12.   */
  13.   p_segname varchar2(100);
  14.   p_type varchar2(30);
  15.   p_owner varchar2(30);
  16.   p_partition varchar2(50);

  17.   l_unformatted_blocks number;
  18.   l_unformatted_bytes number;
  19.   l_fs1_blocks number;
  20.   l_fs1_bytes number;
  21.   l_fs2_blocks number;
  22.   l_fs2_bytes number;
  23.   l_fs3_blocks number;
  24.   l_fs3_bytes number;
  25.   l_fs4_blocks number;
  26.   l_fs4_bytes number;
  27.   l_full_blocks number;
  28.   l_full_bytes number;
  29.   l_free_blks number;
  30.   l_total_blocks number;
  31.   l_total_bytes number;
  32.   l_unused_blocks number;
  33.   l_unused_bytes number;
  34.   l_lastusedextfileid number;
  35.   l_lastusedextblockid number;
  36.   l_last_used_block number;

  37.   procedure p(p_label in varchar2, p_num in number) is
  38.   begin
  39.     dbms_output.put_line(rpad(p_label, 40, '.') || p_num);
  40.   end;
  41. begin
  42.   p_segname := upper(p_segname_1);
  43.   p_owner := upper(p_owner_1);
  44.   p_type := p_type_1;
  45.   p_partition := upper(p_partition_1);

  46.   if (p_type_1 = 'i' or p_type_1 = 'i') then
  47.     p_type := 'index';
  48.   end if;

  49.   if (p_type_1 = 't' or p_type_1 = 't') then
  50.     p_type := 'table';
  51.   end if;

  52.   if (p_type_1 = 'tp' or p_type_1 = 'tp') then
  53.     p_type := 'table partition';
  54.   end if;

  55.   if (p_type_1 = 'ip' or p_type_1 = 'ip') then
  56.     p_type := 'index partition';
  57.   end if;

  58.   if (p_type_1 = 'c' or p_type_1 = 'c') then
  59.     p_type := 'cluster';
  60.   end if;

  61.   dbms_space.unused_space(segment_owner => p_owner,
  62.                           segment_name => p_segname,
  63.                           segment_type => p_type,
  64.                           partition_name => p_partition,
  65.                           total_blocks => l_total_blocks,
  66.                           total_bytes => l_total_bytes,
  67.                           unused_blocks => l_unused_blocks,
  68.                           unused_bytes => l_unused_bytes,
  69.                           last_used_extent_file_id => l_lastusedextfileid,
  70.                           last_used_extent_block_id => l_lastusedextblockid,
  71.                           last_used_block => l_last_used_block);

  72.   if p_space = 'manual' or (p_space <> 'auto' and p_space <> 'auto') then
  73.     dbms_space.free_blocks(segment_owner => p_owner,
  74.                            segment_name => p_segname,
  75.                            segment_type => p_type,
  76.                            partition_name => p_partition,
  77.                            freelist_group_id => 0,
  78.                            free_blks => l_free_blks);
  79.   
  80.     p('free blocks', l_free_blks);
  81.   end if;

  82.   p('total blocks', l_total_blocks);
  83.   p('total bytes(mb)', round(l_total_bytes/1024/1024,1));
  84.   p('unused blocks', l_unused_blocks);
  85.   p('unused bytes(mb)', round(l_unused_bytes/1024/1024,1));
  86.   p('last used ext fileid', l_lastusedextfileid);
  87.   p('last used ext blockid', l_lastusedextblockid);
  88.   p('last used block', l_last_used_block);

  89.   /*if the segment is analyzed */
  90.   if p_analyzed = 'y' then
  91.     dbms_space.space_usage(segment_owner => p_owner,
  92.                            segment_name => p_segname,
  93.                            segment_type => p_type,
  94.                            partition_name => p_partition,
  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(mb)', round(l_fs1_bytes/1024/1024,1));
  111.     p('25% -- 50% free space blocks', l_fs2_blocks);
  112.     p('25% -- 50% free space bytes(mb)', round(l_fs2_bytes/1024/1024,1));
  113.     p('50% -- 75% free space blocks', l_fs3_blocks);
  114.     p('50% -- 75% free space bytes(mb)', round(l_fs3_bytes/1024/1024,1));
  115.     p('75% -- 100% free space blocks', l_fs4_blocks);
  116.     p('75% -- 100% free space bytes(mb)', round(l_fs4_bytes/1024/1024,1));
  117.     p('unused blocks', l_unformatted_blocks);
  118.     p('unused bytes(mb)', round(l_unformatted_bytes/1024/1024,1));
  119.     p('total blocks', l_full_blocks);
  120.     p('total bytes(mb)', round(l_full_bytes/1024/1024,1));
  121.   end if;
  122. end;
  123. /


效果图


效果图2

阅读(838) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图