LISTAGG之取索引对应列名称

来源:互联网 发布:无间道歌曲 知乎 编辑:程序博客网 时间:2024/04/29 13:47

SQL> select uc.TABLE_NAME,  2         uc.INDEX_NAME,  3         listagg(uc.COLUMN_NAME, ',') within group(order by uc.COLUMN_POSITION) as cols  4    from user_ind_columns uc  5   group by uc.TABLE_NAME, uc.INDEX_NAME  6  / TABLE_NAME  INDEX_NAME   COLS      ----------- ------------ ----------T1          IDX_T1       ID,OWNEREMP         PK_EMP       EMPNODEPT        PK_DEPT      DEPTNO

增加排序属性显示

select uc.TABLE_NAME,       uc.INDEX_NAME,       listagg(uc.COLUMN_NAME || ' ' || uc.DESCEND, ',') within group(order by uc.COLUMN_POSITION) as cols  from user_ind_columns uc group by uc.TABLE_NAME, uc.INDEX_NAME;


原创粉丝点击