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

Primary & secondary keys


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

New User


Joined: 13 Feb 2008
Posts: 9
Location: hyderabad

PostPosted: Wed Apr 16, 2008 7:11 pm
Reply with quote

How do we knoe the primary key and seondary key of particular DB2 table from DB2 tools option.

I have selected Db2>T>ADM>DB2 system catalog > Enter the table name and Owner name and selected T > PK

But no rows were selected.


Could you please let me if there is nay other way to find out the primary and secondary key.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Wed Apr 16, 2008 7:19 pm
Reply with quote

primary key and seondary key of particular DB2 table???
Back to top
View user's profile Send private message
praveen_kandrakota

New User


Joined: 13 Feb 2008
Posts: 9
Location: hyderabad

PostPosted: Wed Apr 16, 2008 7:24 pm
Reply with quote

Primary key and secondary keys of Db2 table
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Apr 17, 2008 12:59 am
Reply with quote

Look at the indexes. Use X on the line where the table is displayed. You should get a screen like the following.

Code:

DB2 Admin --------------------- D2WA Indexes ----------------- Row 1 to 1 of 1
Command ===>                                                  Scroll ===> CSR 
                                                                               
Commands: DIS  STA  STO                                                       
Line commands:                                                                 
 T - Tables  D - Database  G - Storage group  P - Plans  C - Columns           
 DIS - Display index space  STA - Start index space  STO - Stop index space   
 ? - Show all line commands                                                   
                                                                               
                          Index                       Table             C C C 
Select Index Name         Owner    Table Name         Owner    U   Cols G D L T
       *                  *        *                  *        *      * * * * *
------ ------------------ -------- ------------------ -------- - ------ - - - -
       IDX1               OWNER    TABLE_NAME_T       OWNER    P      2 Y N Y 2


a P in the U column indicates it is a primary key. Check the help on this screen for what the data means.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Apr 17, 2008 1:00 am
Reply with quote

A table can have a primary key and a foreign key in a database. Anything else is referred to as an Index and using X on the line showing the table you want will give you the indexes for that table. Once you get the indexes you put a C in front of the index name to get the columns in that index.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Apr 17, 2008 2:28 am
Reply with quote

Hi,

If BMC Software for DB2 is installed at your site, there are some easiser way to check for the primary key..
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 Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Use input file with OMIT rcd keys? DFSORT/ICETOOL 15
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
Search our Forums:

Back to Top