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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Primary Key

Re: Primary Key

From: Greg Vitetzakis <greg_at_ostnet.com>
Date: Wed, 28 Feb 2001 13:28:34 -0500
Message-ID: <3a9d433d@news1>

Try this: It will return the Primary Key Name and the fields that make up the PK.

SELECT UCC.CONSTRAINT_NAME, UCC.COLUMN_NAME FROM USER_CONSTRAINTS UC, USER_CONS_COLUMNS UCC

WHERE UC.CONSTRAINT_TYPE = 'P'        --PRIMARY KEY   'P'
                                                                         --
FOREIGN KEY 'F'
AND UC.TABLE_NAME = '*********'
AND UC.CONSTRAINT_NAME = UCC.CONSTRAINT_NAME
AND UC.TABLE_NAME = UCC.TABLE_NAME

ORDER BY UCC.POSITION
/

Greg Vitetzakis V Greg Vitetzakis V.P. Professional Services OSTnet (Open Source Technologies Inc.) www.ostnet.com

"Peter Chase" <chasep99_at_excite.ca> wrote in message news:Mj9n6.1967$br1.49775_at_sodalite.nbnet.nb.ca...
> I am using Oracle 8i Personal Edition. Is there an sql statement that I
 can
> use that will return the primary key for a given table.
>
>
Received on Wed Feb 28 2001 - 12:28:34 CST

Original text of this message

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