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: How to get primary key

Re: How to get primary key

From: Stephen Bell <stephen.bell_at_cgi.ca>
Date: Mon, 09 Jul 2001 08:13:17 -0400
Message-ID: <3B499FDC.5EF74255@cgi.ca>

Thanks Sybrand,

I had to change 'column_position' to 'position' for it to work but this is a handy script to keep ....

Best regards,
Steve

Sybrand Bakker wrote:

> "Florian Hieke" <florian.hieke_at_t-online.de> wrote in message
> news:3B46D8A8.7050808_at_t-online.de...
> > Hi,
> > maybe it's quite a silly question but is there a way to get a table's
> > primary key via SQL or PL/SQL? I'm thankful for any hint.
> > Thanks, Florian
> >
>
> select column_name
> , column_position
> from user_cons_columns cc
> , user_constraints c
> where c.table_name = '<your table>'
> and c.constraint_type = 'P'
> and cc.constraint_name = c.constraint_name
>
> Hth,
>
> Sybrand Bakker, Senior Oracle DBA
Received on Mon Jul 09 2001 - 07:13:17 CDT

Original text of this message

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