Retrieving catalog information about primary keys

The SYSIBM.SYSCOLUMNS table identifies columns of a primary key in column KEYSEQ; a nonzero value indicates the place of a column in the primary key.

Procedure

Begin general-use programming interface information.

To obtain catalog information about primary keys:

Query the SYSIBM.SYSCOLUMNS table.
To retrieve the creator, database, and names of the columns in the primary key of the sample project activity table using SQL statements, execute:
SELECT TBCREATOR, TBNAME, NAME, KEYSEQ
  FROM SYSIBM.SYSCOLUMNS
  WHERE TBCREATOR = 'DSN8C10'
  AND TBNAME = 'PROJACT'
  AND KEYSEQ > 0
    ORDER BY KEYSEQ;
The SYSIBM.SYSINDEXES table identifies the primary index of a table by the value P in column UNIQUERULE. To find the name, creator, database, and index space of the primary index on the project activity table, execute:
SELECT TBCREATOR, TBNAME, NAME, CREATOR, DBNAME, INDEXSPACE
  FROM SYSIBM.SYSINDEXES
  WHERE TBCREATOR = 'DSN8C10'
  AND TBNAME = 'PROJACT'
  AND UNIQUERULE = 'P';

End general-use programming interface information.