Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding index_name

vpolasaFeb 9 2015 — edited Feb 10 2015

We have temporary table where we store details of the index (to be created or dropped). How can we find an index name based on the column names, position and table name. Below are the details I'm trying:

MI_INDEXES_MASTER     

INDX_KEYTABLE_NAMEUNIQUENESSCOLUMN_NAMEALTER_CONDITIONCOLUMN_POSITION
261MI_READING0UNIQUEMI_READING0_RDG_TAKEN_DT_DDROP1
261MI_READING0UNIQUEMI_READING0_RDG_VAL_CHAR_CDROP2
261MI_READING0UNIQUEMI_READING0_RDG_VAL_NUM_NDROP3
261MI_READING0UNIQUEMI_READING0_RELAT_ML_ENTIT_KEYDROP4
261MI_READING0UNIQUEFMLY_KEYDROP5

I'm trying with the below query but unable to get the index name, if there are other indexes with same fields but different positions or same number of fields but few different fields.

SELECT DISTINCT uic.index_name

FROM mi_indexes_master mi

JOIN user_ind_columns uic

ON uic.table_name       = mi.table_name

AND uic.column_name     = mi.column_name

AND uic.column_position = mi.column_position

JOIN user_indexes ui

ON ui.uniqueness  = mi.uniqueness

AND ui.index_name = uic.index_name

WHERE mi.indx_key = 261;

Using Oracle 11g on Win7

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2015
Added on Feb 9 2015
9 comments
822 views