Friday, June 13, 2014

How to know table Indexes in Oracle Database

To know the number indexes and index type of each can be found using view "USER_INDEXES"

example:

select * from user_indexes where table_name='WC_ORG_ATTR_D';





Index_Name         
Index_Type
Owner
Table_Name
Table_Type
Uniquness
Compression
WC_ORG_ATTR_D_U2
NORMAL
DWH
WC_ORG_ATTR_D
TABLE
UNIQUE
DISABLED
WC_ORG_ATTR_D_U1
NORMAL
DWH
WC_ORG_ATTR_D
TABLE
UNIQUE
DISABLED


to know the column names where indexes created can be found using "DBA_IND_COLUMNS" or "USER_IND_COLUMNS"
example:
select * from dba_ind_columns where table_name='WC_ORG_ATTR_D';



Index_Owner
Index_Name
Table_Owner
Table_Name
Column_Name
DWH
WC_ORG_ATTR_D_U2
DWH
WC_ORG_ATTR_D
INTEGRATION_ID
DWH
WC_ORG_ATTR_D_U2
DWH
WC_ORG_ATTR_D
DATASOURCE_NUM_ID
DWH
WC_ORG_ATTR_D_U2
DWH
WC_ORG_ATTR_D
EFFECTIVE_FROM_DT
DWH
WC_ORG_ATTR_D_U1
DWH
WC_ORG_ATTR_D
ROW_WID




Here is the consolidated query to find table name,column name and index names.

SELECT user_tables.table_name,
user_indexes.index_name,
user_ind_columns.column_name
FROM user_tables
JOIN user_indexes on user_indexes.table_name = user_tables.table_name
JOIN user_ind_columns ON user_indexes.index_name = user_ind_columns.index_name
where user_indexes.table_name = 'WC_ORG_ATTR_D'
ORDER BY user_tables.table_name,user_indexes.index_name;






No comments:

Post a Comment