select
case
when (mn.minix = si.name and sk.colseq = 1) then si.tbname
else ' '
end table_nme,
case
when (sk.colseq = 1) then si.name
else ' '
end index_nme,
sk.colname,
case
when sc.coltype = 'CHAR'
then strip(sc.coltype) || '(' || varchar(sc.length) || ')'
when sc.coltype = 'FLOAT' and sc.length = 2
then 'DOUBLE'
when sc.coltype = 'VARCHAR'
then strip(sc.coltype) || '(' || varchar(sc.length) || ')'
when sc.coltype = 'DECIMAL'
then strip(sc.coltype) || '(' || varchar(sc.length) || ', ' || varchar(scale) || ')'
else sc.coltype
end as coltype,
sk.colseq,
case
when (sk.colseq = 1) then ' ' || si.UNIQUERULE
else ' '
end UNIQUERULE
from sysibm.sysindexes si
join
sysibm.syskeys sk
on si.name = sk.ixname
join
sysibm.syscolumns sc
on sc.tbname = si.tbname
and
sc.name = sk.colname
and
sc.tbcreator = si.tbcreator
join table
(select min(name) minix
from sysibm.sysindexes mn
where mn.tbcreator = sc.tbcreator
and mn.tbname = si.tbname
) mn
on 1 = 1
where si.tbname in (ucase('???????'))
and
si.tbcreator = '???????'
order by si.tbname, si.name, sk.colseq;
with ur;
You have to change '???????' by existing table name and by table creator, and you'll have the looking good report with all indexes on the table together with columns names and types of columns.
Lenny K. (Citigroup, NY-NJ)