-- 查询没有建立索引的的外键字段 并生成 创建索引语句
select lower('create index ' || 'idx_' || x.c || ' on ' || x.t || '(' || x.c || ');') sqls
from (
select c.table_name t,
c.column_name c
from user_cons_columns c,
user_constraints uc
where c.table_name = uc.table_name
and c.constraint_name = uc.constraint_name
and uc.constraint_type = 'R'
and uc.status = 'ENABLED'
minus
select ui.table_name t,
ui.column_name c
from user_ind_columns ui) x;
-- 一般所有查询
select c.index_name,
i.table_name,
c.column_name
from user_ind_columns c,
user_indexes i
where c.index_name = i.index_name
and c.table_name = i.table_name
and i.table_name = 'CUSTOMER'