As everyone aware that when TABLE is created in DB2, the details store in DB2 SYSTEM catalog tables.
To check PRIMARY KEY you need to write a SQL query on SYSIBM.SYSCOLUMNS catalog table:
There are 2 ways can see Primary Key Column name:
- Using Tools like BMC/ Toad Tools
- Other way is using SQL Query
Below SQL query works to know primary key:
SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBNAME = 'DEPT' AND TBCREATOR = 'DSN8910' AND KEYSEQ>0 GROUPBY KEYSEQ ASC;
From the result of above query you will get column name on which primary key is defined.