Select columns of table index

强颜欢笑 提交于 2021-02-17 05:41:05

问题


Oracle has a query that selects the existing indexes of a table. For example:

SELECT * FROM user_indexes WHERE table_name = 'CM_WCEL';

But I need to recreate the index creation statement. How can I get the remaining information like the affected columns, etc?


回答1:


To get the complete DDL for each index, use dbms_metadata.get_ddl():

select index_name, dbms_metadata.get_ddl('INDEX', index_name) as ddl
from user_indexes
where table_name = CM_WCEL';

The DDL is returned as a CLOB. Depending on the SQL client you are using you might need some configuration changes to be able to see the complete code. e.g. in SQL*Plus you need something set long 60000 before you run the select statement.




回答2:


As per the creation of table, the below tables will have the requested information.

SELECT *
FROM user_ind_columns
WHERE table_name = 'CM_WCEL';

or

SELECT *
FROM dba_ind_columns
WHERE table_name = 'CM_WCEL';



回答3:


this should provide needed information:

 select index_name, column_name
 from user_ind_columns
 where table_name = 'CM_WCEL';


来源:https://stackoverflow.com/questions/43872487/select-columns-of-table-index

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!