【问题标题】:How to recreate composite index with the help 'all_ind_columns'如何借助“all_ind_columns”重新创建复合索引
【发布时间】:2016-10-17 11:54:36
【问题描述】:

我有一个table(XXX),它在两个columns(A,B) 上有复合索引。我正在使用查询将这些索引提取到另一个表中:

create table YYY as
    select index_name, table_name, column_name
    from all_ind_columns
    where table_name = 'XXX';

我得到表 XXX 的两行,每一行代表不同的 columns(A,B) 但相同的 index_name(INDEX1)

我应该如何以同样的方式重新创建它们。

【问题讨论】:

    标签: sql oracle indexing


    【解决方案1】:

    您可以使用以下查询来生成“创建索引”语句:

     select 
       'create index '
     || index_name 
     ||'  on YYY (' 
     || listagg( column_name, ',') within group (order by column_position) 
     || ');'  
    from all_ind_columns where table_name='XXX' group by index_name;
    

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 1970-01-01
      • 1970-01-01
      • 2015-08-10
      相关资源
      最近更新 更多