IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Find the Primary key of the table with sysibm command


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Asokrani

New User


Joined: 08 Jun 2007
Posts: 18
Location: Connecticut

PostPosted: Wed Jan 23, 2008 12:02 am
Reply with quote

Hi

How can i find the Primary key of the table with sysibm command
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jan 23, 2008 12:40 am
Reply with quote

Asokrani wrote:
Hi

How can i find the Primary key of the table with sysibm command


Try looking in SYSIBM.SYSINDEXES where unique_rule = 'P' and TBNAME = 'yourtablename'

For additional information look in the DB2 SQL Reference.
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jan 23, 2008 3:55 pm
Reply with quote

SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR = <TABLE CREATOR NAME> AND TBNAME = <TABLE NAME> AND KEYSEQ > 0;
Back to top
View user's profile Send private message
the_gautam

Active User


Joined: 05 Jun 2005
Posts: 165
Location: Bangalore

PostPosted: Wed Jan 23, 2008 4:01 pm
Reply with quote

SELECT A.COLNAME, A.COLSEQ, A.ORDERING FROM SYSIBM.SYSKEYS A, SYSIBM.SYSINDEXES B WHERE A.IXNAME=B.NAME AND A.IXCREATOR=B.CREATOR AND B.TBNAME=<TABLE NAME> AND B.TBCREATOR=<TABLE CREATOR> AND B.UNIQUERULE='P';


OR,

SELECT NAME FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR = <TABLE CREATOR NAME> AND TBNAME = <TABLE NAME> AND KEYSEQ > 0;
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top