Re: how can I determine the primary key for a table?

From: Larry W. Virden <lvirden_at_gmail.com>
Date: Mon, 30 Mar 2009 10:44:52 -0700 (PDT)
Message-ID: <b4b9718a-f9f1-457a-98fb-d1520098ad4d_at_l3g2000vba.googlegroups.com>



On Mar 30, 1:28 pm, ddf <orat..._at_msn.com> wrote:

> > How can I determine what column in TABLE_H is the primary key?
>
> One would use either the USER_IND_COLUMNS view (if you're connected as
> the owner) or the ALL_IND_COLUMNS view (if you're connected as someone
> else) to return the actual column name or names configured as the
> primary key:
>
> select index_name, column_name
> from all_ind_columns
> where index_name in
> (select index_name
> from all_indexes
> where table_name = 'TABLE_H'
> and uniqueness = 'UNIQUE')
> order by index_name, column_position;
>
> You'll retrieve one or more rows depending upon how many columns
> comprise the primary key.  

Thank you so much. That is just what I was looking for. Received on Mon Mar 30 2009 - 12:44:52 CDT

Original text of this message