oracle精典存储过程

create or replace view sys.user_indexes

(index_name, index_type, table_owner, table_name, table_type, uniqueness, compression, prefix_length, tablespace_name, ini_trans, max_trans, initial_extent, next_extent, min_extents, max_extents, pct_increase, pct_threshold, include_column, freelists, freelist_groups, pct_free, logging, blevel, leaf_blocks, distinct_keys, avg_leaf_blocks_per_key, avg_data_blocks_per_key, clustering_factor, status, num_rows, sample_size, last_analyzed, degree, instances, partitioned, temporary, generated, secondary, buffer_pool, flash_cache, cell_flash_cache, user_stats, duration, pct_direct_access, ityp_owner, ityp_name, parameters, global_stats, domidx_status, domidx_opstatus, funcidx_status, join_index, iot_redundant_pkey_elim, dropped, visibility, domidx_management, segment_created)

as

select o.name,

       decode(bitand(i.property, 16), 0, '', 'FUNCTION-BASED ') ||

        decode(i.type#, 1, 'NORMAL'||

                          decode(bitand(i.property, 4), 0, '', 4, '/REV'),

                      2, 'BITMAP', 3, 'CLUSTER', 4, 'IOT - TOP',

                      5, 'IOT - NESTED', 6, 'SECONDARY', 7, 'ANSI', 8, 'LOB',

扫描二维码关注公众号,回复: 1345056 查看本文章

                      9, 'DOMAIN'),

       iu.name, io.name,

       decode(io.type#, 0, 'NEXT OBJECT', 1, 'INDEX', 2, 'TABLE', 3, 'CLUSTER',

                       4, 'VIEW', 5, 'SYNONYM', 6, 'SEQUENCE', 'UNDEFINED'),

       decode(bitand(i.property, 1), 0, 'NONUNIQUE', 1, 'UNIQUE', 'UNDEFINED'),

       decode(bitand(i.flags, 32), 0, 'DISABLED', 32, 'ENABLED', null),

       i.spare2,

       decode(bitand(i.property, 34), 0, decode(i.type#, 9, null, ts.name),

           2, null, decode(i.ts#, 0, null, ts.name)),

       to_number(decode(bitand(i.property, 2),2, null, i.initrans)),

       to_number(decode(bitand(i.property, 2),2, null, i.maxtrans)),

       decode(bitand(i.flags, 67108864), 67108864,

                     ds.initial_stg * ts.blocksize,

                     s.iniexts * ts.blocksize),

       decode(bitand(i.flags, 67108864), 67108864,

              ds.next_stg * ts.blocksize,

              s.extsize * ts.blocksize),

       decode(bitand(i.flags, 67108864), 67108864,

              ds.minext_stg, s.minexts),

       decode(bitand(i.flags, 67108864), 67108864,

              ds.maxext_stg, s.maxexts),

       decode(bitand(ts.flags, 3), 1, to_number(NULL),

              decode(bitand(i.flags, 67108864), 67108864,

                            ds.pctinc_stg, s.extpct)),

       decode(i.type#, 4, mod(i.pctthres$,256), NULL), i.trunccnt,

       decode(bitand(ts.flags, 32), 32, to_number(NULL),

       decode(bitand(o.flags, 2), 2, 1,

              decode(bitand(i.flags, 67108864), 67108864,

                     ds.frlins_stg, decode(s.lists, 0, 1, s.lists)))),

       decode(bitand(ts.flags, 32), 32, to_number(NULL),

              decode(bitand(o.flags, 2), 2, 1,

                     decode(bitand(i.flags, 67108864), 67108864,

                            ds.maxins_stg, decode(s.groups, 0, 1, s.groups)))),

       decode(bitand(i.property, 2),0,i.pctfree$,null),

       decode(bitand(i.property, 2), 2, NULL,

                decode(bitand(i.flags, 4), 0, 'YES', 'NO')),

       i.blevel, i.leafcnt, i.distkey, i.lblkkey, i.dblkkey, i.clufac,

       decode(bitand(i.property, 2), 2,

                    decode(i.type#, 9, decode(bitand(i.flags, 8),

                                        8, 'INPROGRS', 'VALID'), 'N/A'),

                     decode(bitand(i.flags, 1), 1, 'UNUSABLE',

                            decode(bitand(i.flags, 8), 8, 'INPROGRS',

                                                'VALID'))),

       rowcnt, samplesize, analyzetime,

       decode(i.degree, 32767, 'DEFAULT', nvl(i.degree,1)),

       decode(i.instances, 32767, 'DEFAULT', nvl(i.instances,1)),

       decode(bitand(i.property, 2), 2, 'YES', 'NO'),

       decode(bitand(o.flags, 2), 0, 'N', 2, 'Y', 'N'),

       decode(bitand(o.flags, 4), 0, 'N', 4, 'Y', 'N'),

       decode(bitand(o.flags, 16), 0, 'N', 16, 'Y', 'N'),

       decode(bitand(o.flags, 2), 2, 'DEFAULT',

              decode(bitand(decode(bitand(i.flags, 67108864), 67108864,

                            ds.bfp_stg, s.cachehint), 3),

                            1, 'KEEP', 2, 'RECYCLE', 'DEFAULT')),

       decode(bitand(o.flags, 2), 2, 'DEFAULT',

              decode(bitand(decode(bitand(i.flags, 67108864), 67108864,

                            ds.bfp_stg, s.cachehint), 12)/4,

                            1, 'KEEP', 2, 'NONE', 'DEFAULT')),

       decode(bitand(o.flags, 2), 2, 'DEFAULT',

              decode(bitand(decode(bitand(i.flags, 67108864), 67108864,

                            ds.bfp_stg, s.cachehint), 48)/16,

                            1, 'KEEP', 2, 'NONE', 'DEFAULT')),

       decode(bitand(i.flags, 64), 0, 'NO', 'YES'),

       decode(bitand(o.flags, 2), 0, NULL,

          decode(bitand(i.property, 64), 64, 'SYS$SESSION', 'SYS$TRANSACTION')),

       decode(bitand(i.flags, 128), 128, mod(trunc(i.pctthres$/256),256),

              decode(i.type#, 4, mod(trunc(i.pctthres$/256),256), NULL)),

       itu.name, ito.name, i.spare4,

       decode(bitand(i.flags, 2048), 0, 'NO', 'YES'),

       decode(i.type#, 9, decode(o.status, 5, 'IDXTYP_INVLD',

                                           1, 'VALID'),  ''),

       decode(i.type#, 9, decode(bitand(i.flags, 16), 16, 'FAILED', 'VALID'), ''),

       decode(bitand(i.property, 16), 0, '',

              decode(bitand(i.flags, 1024), 0, 'ENABLED', 'DISABLED')),

       decode(bitand(i.property, 1024), 1024, 'YES', 'NO'),

       decode(bitand(i.property, 16384), 16384, 'YES', 'NO'),

       decode(bitand(o.flags, 128), 128, 'YES', 'NO'),

       decode(bitand(i.flags,2097152),2097152,'INVISIBLE','VISIBLE'),

       decode(i.type#, 9, decode(bitand(i.property, 2048), 2048,

                               'SYSTEM_MANAGED', 'USER_MANAGED'), ''),

       decode(bitand(i.flags, 67108864), 67108864, 'NO',

              decode(bitand(i.property, 2), 2, 'N/A', 'YES'))

from sys.ts$ ts, sys.seg$ s, sys.user$ iu, sys.obj$ io, sys.ind$ i, sys.obj$ o,

     sys.user$ itu, sys.obj$ ito, sys.deferred_stg$ ds

where o.owner# = userenv('SCHEMAID')

  and o.obj# = i.obj#

  and i.bo# = io.obj#

  and io.owner# = iu.user#

  and bitand(i.flags, 4096) = 0

  and bitand(o.flags, 128) = 0

  and i.ts# = ts.ts# (+)

  and i.file# = s.file# (+)

  and i.block# = s.block# (+)

  and i.ts# = s.ts# (+)

  and i.obj# = ds.obj# (+)

  and i.type# in (1, 2, 3, 4, 6, 7, 8, 9)

  and i.indmethod# = ito.obj# (+)

  and ito.owner# = itu.user# (+);

 

猜你喜欢

转载自zhijie-geng.iteye.com/blog/1700737
今日推荐