DDL :
create or replace view DBA_INDEXES
(OWNER, 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,
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)
as
select u.name, 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',
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), null),
decode(bitand(i.property, 2),0, i.initrans, null),
decode(bitand(i.property, 2),0, i.maxtrans, null),
s.iniexts * ts.blocksize, s.extsize * ts.blocksize,
s.minexts, s.maxexts,
decode(bitand(ts.flags, 3), 1, to_number(NULL),
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(s.lists, 0, 1, s.lists))),
decode(bitand(ts.flags, 32), 32, to_number(NULL),
decode(bitand(o.flags, 2), 2, 1, 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(s.cachehint, 0, 'DEFAULT', 1, 'KEEP', 2, 'RECYCLE', NULL)),
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')
from sys.ts$ ts, sys.seg$ s,
sys.user$ iu, sys.obj$ io, sys.user$ u, sys.ind$ i, sys.obj$ o,
sys.user$ itu, sys.obj$ ito
where u.user# = o.owner#
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.indmethod# = ito.obj# (+)
and ito.owner# = itu.user# (+)
/
create or replace view DBA_IND_COLUMNS
(INDEX_OWNER, INDEX_NAME,
TABLE_OWNER, TABLE_NAME,
COLUMN_NAME, COLUMN_POSITION, COLUMN_LENGTH,
CHAR_LENGTH, DESCEND)
as
select io.name, idx.name, bo.name, base.name,
decode(bitand(c.property, 1024), 1024,
(select decode(bitand(tc.property, 1), 1, ac.name, tc.name)
from sys.col$ tc, attrcol$ ac
where tc.intcol# = c.intcol#-1
and tc.obj# = c.obj#
and tc.obj# = ac.obj#(+)
and tc.intcol# = ac.intcol#(+)),
decode(ac.name, null, c.name, ac.name)),
ic.pos#, c.length, c.spare3,
decode(bitand(c.property, 131072), 131072, 'DESC', 'ASC')
from sys.col$ c, sys.obj$ idx, sys.obj$ base, sys.icol$ ic,
sys.user$ io, sys.user$ bo, sys.ind$ i, sys.attrcol$ ac
where ic.bo# = c.obj#
and decode(bitand(i.property,1024),0,ic.intcol#,ic.spare2) = c.intcol#
and ic.bo# = base.obj#
and io.user# = idx.owner#
and bo.user# = base.owner#
and ic.obj# = idx.obj#
and idx.obj# = i.obj#
and i.type# in (1, 2, 3, 4, 6, 7, 9)
and c.obj# = ac.obj#(+)
and c.intcol# = ac.intcol#(+)
/
lob index 不同于 普通的index , DBA_IND_COLUMNS 视图不反映lob index
你可以通过以下命令查看lob index 对应的column
CREATE TABLE test_lob (
id NUMBER
, xml_file CLOB
, image BLOB
, log_file BFILE
);
SELECT
table_name "Table"
, column_name "Column"
, segment_name "Segment"
, index_name "Index"
FROM user_lobs
WHERE table_name = 'TEST_LOB';
Table Column Segment Index
------------------------------ ------------------------------ ------------------------------ ------------------------------
TEST_LOB XML_FILE SYS_LOB0000092810C00002$$ SYS_IL0000092810C00002$$
TEST_LOB IMAGE SYS_LOB0000092810C00003$$ SYS_IL0000092810C00003$$ |