tags:

views:

51

answers:

1

I jotted down the following query which will list the index name and its columns for a particular table:

select 
b.uniqueness, a.index_name, a.table_name, a.column_name 
from all_ind_columns a, all_indexes b
where a.index_name=b.index_name 
and a.table_name = upper('table_name')
order by a.table_name, a.index_name, a.column_position;

I want to modify this so that if I pass in a view or synonym also it works. Our system has variations of views, synonyms so it will be really helpful to have one query to which i can just supply the name (be it view synonym or table) and it would spit out the indexes and their columns.

+1  A: 

Your query should work for synonyms as well as the tables. However, you seem to expect indexes on views where there are not. Maybe is it materialized views ?

Nicolas.

N. Gasparotto
I would assume he wants indexes from the dependent tables for a view
dpbradley
In that case, it could be tricky, but it needs to work with ALL_DEPENDENCIES and since a view can be based on an other view(s), it probably also needs a hierarchical query (CONNECT BY).
N. Gasparotto
Synonyms can also point to views too.
Gary
and views can in turn point to other views...
dpbradley
yes. it is a view pointint to a materialized view
john