Gossamer Forum
Home : General : Databases and SQL :

Re: [kellner] How to get primary key for table in Oracle?

Quote Reply
Re: [kellner] How to get primary key for table in Oracle? In reply to
Try the SQL command below:

SELECT COL.CONSTRAINT_NAME,COL.COLUMN_NAME,CON.CONSTRAINT_TYPE
FROM USER_CONS_COLUMNS COL, USER_CONSTRAINTS CON
WHERE COL.TABLE_NAME = upper('TABLE_NAME')
AND COL.TABLE_NAME = CON.TABLE_NAME
AND COL.CONSTRAINT_NAME = CON.CONSTRAINT_NAME
AND CON.CONSTRAINT_TYPE='P';

It will be shown the primary key of a table.

TheStone.

B.
Subject Author Views Date
Thread; hot thread How to get primary key for table in Oracle? kellner 64828 Sep 6, 2002, 7:20 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
Aki 63973 Sep 6, 2002, 8:30 AM
Thread; hot thread Re: [Aki] How to get primary key for table in Oracle?
kellner 64197 Sep 6, 2002, 8:59 AM
Post; hot thread Re: [kellner] How to get primary key for table in Oracle?
cornball 63942 Sep 6, 2002, 9:04 AM
Post; hot thread Re: [kellner] How to get primary key for table in Oracle?
Paul 63937 Sep 6, 2002, 9:05 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
Stealth 64169 Sep 6, 2002, 9:20 AM
Thread; hot thread Re: [Stealth] How to get primary key for table in Oracle?
kellner 64288 Sep 6, 2002, 9:43 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
Stealth 64167 Sep 6, 2002, 10:06 AM
Thread; hot thread Re: [Stealth] How to get primary key for table in Oracle?
kellner 64083 Sep 6, 2002, 10:13 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
Aki 64111 Sep 6, 2002, 10:20 AM
Thread; hot thread Re: [Aki] How to get primary key for table in Oracle?
kellner 64112 Sep 6, 2002, 10:24 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
Paul 64068 Sep 6, 2002, 10:34 AM
Post; hot thread Re: [Paul] How to get primary key for table in Oracle?
Stealth 63989 Sep 6, 2002, 11:57 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
cornball 64144 Sep 6, 2002, 10:42 AM
Thread; hot thread Re: [kode] How to get primary key for table in Oracle?
kellner 64034 Sep 6, 2002, 11:59 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
cornball 64067 Sep 6, 2002, 12:05 PM
Thread; hot thread Re: [kode] How to get primary key for table in Oracle?
kellner 63959 Sep 6, 2002, 12:13 PM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
604 63960 Sep 6, 2002, 1:58 PM
Post; hot thread Re: [TheStone] How to get primary key for table in Oracle?
beni333 63329 Jan 9, 2003, 2:44 AM
Thread; hot thread Re: [kellner] How to get primary key for table in Oracle?
anup123 62905 Mar 23, 2003, 12:33 PM
Thread; hot thread How to get primary key for table in Oracle?
sunita_gateway 61550 Mar 23, 2004, 12:58 AM
Thread; hot thread Re: [sunita_gateway] How to get primary key for table in Oracle?
hongtao 56870 Apr 23, 2008, 11:38 AM
Post; hot thread Re: [hongtao] How to get primary key for table in Oracle?
dan 56717 Apr 23, 2008, 3:02 PM