How to see Primary key in a table in DB2
---------See primary key with column name in a table in db2---------------
It will give you.....
Here COMPLAINANT_RESPONDENT table have a composite primary key on three column (FANO,CRSEQ,CR_TYPE)
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.
==========================================================
-------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------
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
Post a Comment