Quantcast
Channel: Fox Infotech
Viewing all articles
Browse latest Browse all 231

Getting Foreign Key Column Names Which Are Not Indexed In Oracle

$
0
0
Suppose you have a standard for your database that all foreign key columns must have indexes created for them and  you want to verify that all foreign key columns are indexed or not.

The following query will get you the names of foreign key columns for which index have not been created in Oracle:

select
a.constraint_name cons_name
,a.table_name tab_name
,b.column_name cons_column
,nvl(c.column_name,'***No Index***') ind_column
from user_constraints a
join
user_cons_columns b on a.constraint_name = b.constraint_name
left outer join
user_ind_columns c on b.column_name = c.column_name
and b.table_name = c.table_name
where constraint_type = 'R'
order by 2,1;


Viewing all articles
Browse latest Browse all 231

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>