View previous topic :: View next topic
|
Author |
Message |
srinut123
New User
Joined: 11 Oct 2005 Posts: 62 Location: India
|
|
|
|
Hi All
What are the different ways to find out the primary key on a table?
Thanks in adv
sri |
|
Back to top |
|
|
rajandhla
Active User
Joined: 18 Oct 2005 Posts: 182 Location: Luton UK
|
|
|
|
Go to the table schema and find out which key is defined as primary or forgein key..etc
else
find the indexed keys on the table and check whether it is defined as unique key or duplicate key. If it is unique it can used as PK..
regards
JR |
|
Back to top |
|
|
Garpen
New User
Joined: 03 Jan 2007 Posts: 14 Location: Sweden
|
|
|
|
Hi
For z/os, check UNIQUERULE i SYSINDEXES, it should be a P |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Try this query:
Code: |
SELECT IX.TBNAME,
KEYS.IXNAME,
IX.UNIQUERULE,
KEYS.COLNAME,
KEYS.COLNO,
KEYS.COLSEQ
FROM SYSIBM.SYSINDEXES IX,
SYSIBM.SYSKEYS KEYS
WHERE IX.TBNAME = 'YOUR_TABLE'
AND KEYS.IXNAME = IX.NAME
ORDER BY IX.TBNAME,
KEYS.IXNAME,
KEYS.COLSEQ
|
|
|
Back to top |
|
|
|