If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Find PrimaryKey Columns...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-21-06, 10:39
VitaminB VitaminB is offline
Registered User
 
Join Date: Jun 2004
Posts: 21
Find PrimaryKey Columns...

Hi Guys,

can anybody tell me how to find out which columns are member of the primary key from any table in a DB2 database?

Thanks,
Marc
Reply With Quote
  #2 (permalink)  
Old 05-22-06, 04:37
ggnanaraj ggnanaraj is offline
Registered User
 
Join Date: Aug 2002
Location: Chennai, India
Posts: 171
One way to do this is to use db2look utility...

db2look -d test -e -a -t employee -o employee.ddl

Where 'test' is the database name & 'employee' is the table name.

The output file employee.ddl will have the DDL for employee table which will also have the primary key SQL statement.

You can also use the syscat.keycoluse catalog table to get this information.

HTH.
Reply With Quote
  #3 (permalink)  
Old 05-22-06, 05:29
VitaminB VitaminB is offline
Registered User
 
Join Date: Jun 2004
Posts: 21
Thnak you...

Thank you! Did found it in the DB2 catalog tables/views.

Regards,
Marc

Last edited by VitaminB; 05-22-06 at 05:34.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On