Thursday, December 3, 2015

How to find the index details of a table

Query:
=====

set lines 300 pages 300
col OWNER for a15
col INDEX_NAME for a25
col TABLE_NAME for a25
col COLUMN_NAME for a25
col TABLE_OWNER for a15
col INDEX_TYPE for a15
select distinct c.index_name, i.uniqueness, c.column_name, c.column_position
from dba_ind_columns c, dba_indexes i
where upper(c.table_name) = upper('&table_name')
and upper(c.table_owner) = upper('&owner')
and c.index_name = i.index_name
and c.index_owner = i.owner
order by index_name, column_position
/

INPUT: Table_owner and Table_name


Partition Index:
===========


set lines 300 pages 3000
col high_value for a100
col INDEX_OWNER for a15
select INDEX_OWNER,INDEX_NAME,PARTITION_NAME,TABLESPACE_NAME,STATUS from dba_ind_partitions where INDEX_OWNER='&INDEX_OWNER' and INDEX_NAME='&INDEX_NAME'
order by PARTITION_NAME;

INPUT: Index_Owner and Index_name

Index on which Columns:
==================

set lines 300 pages 300
col INDEX_OWNER for a15
col INDEX_NAME for a25
col TABLE_NAME for a25
col COLUMN_NAME for a25
col TABLE_OWNER for a15
select INDEX_OWNER,INDEX_NAME,TABLE_OWNER,TABLE_NAME,COLUMN_NAME,COLUMN_POSITION from dba_ind_columns where INDEX_OWNER='&INDEX_OWNER' and INDEX_NAME='&INDEX_NAME';

INPUT: Index_Owner and Index_name


No comments:

Post a Comment