oracle 如何在oracle中查找表、视图和同义词的所有索引及其列

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3018094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 02:38:25  来源:igfitidea点击:

how to find all indexes and their columns for tables, views and synonyms in oracle

oracle

提问by john

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 viewor synonymalso 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.

我想修改它,以便如果我传入 aview或者synonym它也可以工作。我们的系统有不同的视图、同义词,所以有一个我可以只提供名称的查询(无论是视图同义词还是表),它会吐出索引及其列,这将非常有帮助。

采纳答案by N. Gasparotto

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 ?

您的查询应该适用于同义词和表。但是,您似乎希望在没有索引的视图上建立索引。也许是物化视图?

回答by Bala Kumar

SELECT * FROM user_cons_columns WHERE table_name = 'table_name';

SELECT * FROM user_cons_columns WHERE table_name = 'table_name';