How to find the primary key of a particular table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aniket sonmale
    New Member
    • Jan 2011
    • 7

    How to find the primary key of a particular table?

    hi,

    i am working on db2.
    how can i check for a particular table,the primary key of that table.
    for eg. in table REGISTRATION their are around 20 columns. how to check which is the primary key of that table
  • deepak n
    New Member
    • Dec 2010
    • 3

    #2
    Try the following query

    SELECT sc.name
    FROM SYSIBM.SYSCOLUM NS SC
    WHERE SC.TBNAME = 'REGISTRATION'
    AND sc.identity ='N'
    AND sc.tbcreator=sc hemaname
    AND sc.keyseq=1

    Comment

    • Aniket sonmale
      New Member
      • Jan 2011
      • 7

      #3
      It worked.

      Thank you deepak

      Comment

      Working...