Skip to content

Instantly share code, notes, and snippets.

@modul8com
Created December 2, 2013 14:19
Show Gist options
  • Save modul8com/7750135 to your computer and use it in GitHub Desktop.
Save modul8com/7750135 to your computer and use it in GitHub Desktop.
Check if there are tables that contain foreign keys that don't have an index yet
select /*+ first_rows */
c.owner
, c.table_name
, c.constraint_name
from
user_constraints c
where not exists
( select 1
from
user_cons_columns cc
, user_ind_columns ic
where cc.table_name=c.table_name
and cc.constraint_name=c.constraint_name
and cc.table_name=ic.table_name
and cc.column_name = ic.column_name
)
and c.constraint_type = 'R';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment