zOs/SQL/CATIXKEY

                -- redundante indexe, d.h. key sequence prefix
                -- keys eines indexes in der form a<b>c|d<
                --             a,b,c,d keys
                --             <>| ascending, descending, random
with k (cr, ix, tbCr, tb, uni, unC, keys, colCount, kCnt) as
                -- start selektiere Indexe
( select creator, name                      -- start selektiere Indexe
      , tbCreator, tbName, uniqueRule, unique_Count
      ,  cast('' as varchar(1500) ccsid unicode), colCount, 0
      from sysibm.sysIndexes
      where dbName like 'DSNDB%'--  and tbCreator = 'OA1P'
                -- Rekursion: nächster key
  union all select cr, ix, tbCr, tb, uni, unC
          , keys || strip(q.colName)
            || case when ordering = 'A' then '<'
                    when ordering = 'D' then '>'
                    when ordering = 'R' then '|'
                    else '?' end,
          k.colCount, kCnt + 1
       from k
         join sysibm.sysKeys q
         on q.ixCreator = k.cr and q.ixName = k.ix
             and q.colSeq = kCnt + 1
         where kCnt < 9999
)
, l as
(
   select k.*,
       translate(strip(keys), ',,,,', '<>|?') keyU
     from k
    where colCount = kCnt
)
, r as
(
  select a.*
    from l a
    where exists ( select 1 from l b
         where a.tbCr = b.tbCr and a.tb = b.tb
             and not (a.cr = b.cr and a.ix = b.ix)
             and ( left(a.keys, length(b.keys)) = b.keys
                 or a.keys = left(b.keys, length(a.keys)) )
         )
)
select substr(strip(tbCr) || '.' || tb, 1, 20) table
    ,  substr(strip(cr) || '.' || ix, 1, 20) index
    ,  uni, smallint(colCount) "#keys", unC, keys
    ,  tbcr, tb, cr, ix
    from r
    order by tbcr, tb, keys
;
;x;
                -- keys eines indexes in der form a<b>c|d<
                --             a,b,c,d keys
                --             <>| ascending, descending, random
with k (cr, ix, keys, cols, kCnt) as
                -- start selektiere Indexe
( select creator, name,     -- start selektiere Indexe
        cast('' as varchar(500) ccsid unicode), colCount, 0
      from sysibm.sysIndexes
      where tbCreator = 'OA1P'  and tbName in ( 'TDG122A1'
                                              , 'TDG127A1'
                                              , 'TDG127K1'
                                              , 'TDG128A1'
                                              , 'TDG128K1'
                                              , 'TDG132A1'
                                              , 'TDG132K1'
                                              , 'TDG154A1'
                                              , 'TDG210A0'
                                              , 'TDG310A0'
                                              , 'TDG320A1'
                                              , 'TDG570A0'
                                              , 'TDG900A0'
                                              , 'TDG950A0'
                                              , 'TDG950A1'
                                              , 'TDG970A0'
                                              , 'TDG990A0'
                                              )
                -- Rekursion: nächster key
  union all select cr, ix, keys || strip(q.colName)
            || case when ordering = 'A' then '<'
                    when ordering = 'D' then '>'
                    when ordering = 'R' then '|'
                    else '?' || ordering || '?' end,
          k.cols, kCnt + 1
       from k
         join sysibm.sysKeys q
         on q.ixCreator = k.cr and q.ixName = k.ix
             and q.colSeq = kCnt + 1
         where kCnt < 9999
)
select substr(strip(i.tbCreator) || '.' || strip(i.tbName), 1, 20) tb
       , substr(strip(cr) || '.' || strip(ix), 1, 20) ix
       , i.uniqueRule uni
       , smallint(cols), keys
    from k join sysibm.sysIndexes i
      on k.cr = i.creator and k.ix = i.name
    where cols = kCnt
    order by i.tbCreator, i.tbName, keys, cr, ix
;x;
                -- keys eines indexes in der form a<b>c|d<
                --             a,b,c,d keys
                --             <>| ascending, descending, random
with k (cr, ix, keys, colCount, kCnt) as
                -- start selektiere Indexe
( select creator, name,     -- start selektiere Indexe
        cast('' as varchar(500) ccsid unicode), colCount, 0
      from sysibm.sysIndexes
      where creator = 'OA1T'  and tbName like 'TWM005A1'
                -- Rekursion: nächster key
  union all select cr, ix, keys || strip(q.colName)
            || case when ordering = 'A' then '<'
                    when ordering = 'D' then '>'
                    when ordering = 'R' then '|'
                    else '?' || ordering || '?' end,
          k.colCount, kCnt + 1
       from k
         join sysibm.sysKeys q
         on q.ixCreator = k.cr and q.ixName = k.ix
             and q.colSeq = kCnt + 1
         where kCnt < 9999
)
select substr(strip(cr) || '.' || strip(ix), 1, 20),
       smallint(colCount), keys
    from k
    where colCount = kCnt
    order by cr, ix
;x;