Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1209563
  • 博文数量: 398
  • 博客积分: 10110
  • 博客等级: 上将
  • 技术积分: 4055
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-23 20:01
个人简介

新博客http://www.cnblogs.com/zhjh256 欢迎访问

文章分类

全部博文(398)

文章存档

2012年(1)

2011年(41)

2010年(16)

2009年(98)

2008年(142)

2007年(100)

我的朋友

分类: Oracle

2007-12-26 12:14:38

检测下一次扩展将失败的对象
 
select owner,
       segment_name,
       segment_type,
       seg.tablespace_name,
       decode(ext.allocation_type, 'USER', next_extent, ext.min_extlen) next,
       ext.largest_free_extent,
       extents,
       max_extents
  from dba_segments seg,
       (select d.TABLESPACE_NAME,
               nvl(max(f.bytes), 0) largest_free_extent,
               t.allocation_type,
               t.min_extlen
          from dba_free_space f, dba_data_files d, dba_tablespaces t
         where f.tablespace_name(+) = d.tablespace_name
           and d.tablespace_name = t.tablespace_name
         group by d.tablespace_name, t.allocation_type, t.min_extlen) ext
 where seg.tablespace_name = ext.tablespace_name
   and (decode(ext.allocation_type, 'USER', next_extent, ext.min_extlen) >
       ext.largest_free_extent or seg.extents = seg.max_extents);
 

select b.tablespace_name "Tablespace",
       b.segment_type "Type",
       substr(ext.owner || '.' || ext.segment_name, 1, 50) "Object Name",
       To_Char(decode(freespace.Extent_Management,
                      'DICTIONARY',
                      decode(b.extents,
                             1,
                             b.next_extent,
                             ext.bytes * (1 + b.pct_increase / 100)),
                      'LOCAL',
                      decode(freespace.Allocation_Type,
                             'UNIFORM',
                             freespace.INITIAL_EXTENT,
                             'SYSTEM',
                             ext.bytes)) / 1024,
               '9,999,999,999') "Required Extent(K)",
       to_char(freespace.largest / 1024, '9,999,999,999') "MaxAvail K"
  from dba_segments b,
       dba_extents ext,
       (select B.tablespace_name,
               B.Extent_Management,
               B.Allocation_Type,
               B.INITIAL_EXTENT,
               B.NEXT_EXTENT,
               max(A.bytes) largest
          from dba_free_space A, dba_tablespaces B
         Where B.Tablespace_Name = A.Tablespace_Name
           And B.Status = 'ONLINE'
         group by B.tablespace_name,
                  B.Extent_Management,
                  B.Allocation_Type,
                  B.INITIAL_EXTENT,
                  B.NEXT_EXTENT) freespace
 where b.owner = ext.owner
   and b.segment_type = ext.segment_type
   and b.segment_name = ext.segment_name
   and b.tablespace_name = ext.tablespace_name
   and (b.extents - 1) = ext.extent_id
   and b.tablespace_name = freespace.tablespace_name
   and decode(freespace.Extent_Management,
              'DICTIONARY',
              decode(b.extents,
                     1,
                     (b.next_extent),
                     ext.bytes * (1 + b.pct_increase / 100)),
              'LOCAL',
              decode(freespace.Allocation_Type,
                     'UNIFORM',
                     freespace.INITIAL_EXTENT,
                     'SYSTEM',
                     ext.bytes)) > freespace.largest
 order by b.Tablespace_Name, b.Segment_Type, b.Segment_Name
阅读(545) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~