Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Primary Key

Primary Key

From: Norman Dunbar <Norman.Dunbar_at_lfs.co.uk>
Date: Tue, 12 Mar 2002 09:13:59 -0000
Message-ID: <E2F6A70FE45242488C865C3BC1245DA70150C51C@lnewton.leeds.lfs.co.uk>


-----Original Message-----
From: Kram [mailto:myoung_at_optushome.com.au] Posted At: Tuesday, March 12, 2002 5:43 AM Posted To: server
Conversation: Primary Key
Subject: Primary Key

>> How do I find the primary key of a table?

SELECT constraint_name FROM user_constraints WHERE constraint_type = 'P' AND
table_name = <appropriate_table_name> ;

Now, how do you find the primary key columns and in the correct order ?

SELECT column_name FROM user_cons_columns WHERE constraint_name = (

	SELECT constraint_name FROM user_constraints
	WHERE constraint_type = 'P' AND
	table_name = <appropriate_table_name>

)
ORDER BY position ;

HTH regards,
Norman.



Norman Dunbar			EMail:	Norman.Dunbar_at_LFS.co.uk
Database/Unix administrator	Phone:	0113 289 6265
				Fax:	0113 289 3146
Lynx Financial Systems Ltd.	URL:	http://www.Lynx-FS.com
------------------------------------------------------------------------

Received on Tue Mar 12 2002 - 03:13:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US