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)

Popular posts from this blog

Android: where to run keytool command in android

Can not connect to git using ssh (Permissions 0644 for '/root/.ssh/id_rsa' are too open.

Upload file on Google cloud storage using Java servlet on google app engine