How to see Primary key in a table in DB2

---------See primary key with column name in a table in db2---------------
db2  "select constname,tabname,colname from syscat.keycoluse where tabname='TABLENAME' "

It will give you.....

Example:::  

db2inst1@confonet:~> db2 "select constname,tabname,colname from syscat.keycoluse where tabname='COMPLAINANT_RESPONDENT'"

--------------Output--------------------------------
CONSTNAME                                                                                                                        TABNAME                                                                                                                          COLNAME                                                                                                             
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
SQL100416165400090                                                                                                               COMPLAINANT_RESPONDENT                                                                                                           CRSEQ                                                                                                               
SQL100416165400090                                                                                                               COMPLAINANT_RESPONDENT                                                                                                           CR_TYPE                                                                                                             
SQL100416165400090                                                                                                               COMPLAINANT_RESPONDENT                                                                                                           FANO                                                                                                                

  3 record(s) selected.
==========================================================

Here COMPLAINANT_RESPONDENT table have a composite primary key on three column (FANO,CRSEQ,CR_TYPE)

Comments

Popular posts from this blog

Read Images from a xlsx file using Apache POI

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

How to create mail message in FRC822 format