Re: How to get the name of a table's primary key? - Mailing list pgsql-general

From Christian von Kietzell
Subject Re: How to get the name of a table's primary key?
Date
Msg-id 20020316204612.A8716@wh2-227.uni-magdeburg.de
Whole thread Raw
In response to Re: How to get the name of a table's primary key?  (Darren Ferguson <darren@crystalballinc.com>)
Responses Re: How to get the name of a table's primary key?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

On Fri, Mar 15, 2002 at 11:47:27AM -0500, Darren Ferguson wrote:
> You can give the primary key a name when you are creating the table just
> like you can give indexes, foreign keys, unique etc
>
> create table foo (
>    foo_pkey integer not null,
>    foo_data varchar(50) not null,
>    CONSTRAINT foo_pk PRIMARY KEY(poo_pkey)
> )
> ;
>
> The primary key for this table is called foo_pk

Well, that isn't quite what I meant. I know I can do that. Maybe my
explanation was a bit misleading.

Suppose, I've got the table shown above. I've only got its name. What
I want is the column name the primary key is created on. How can I do
that? Basically, which of foo_pkey and foo_data is the primary key?

Cheers,
  Chris

--
Christian von Kietzell
mailto: chris@gammu.ath.cx
Jabber: cuboci@charente.de

pgsql-general by date:

Previous
From: "Jonathan Ellis"
Date:
Subject: locking problems
Next
From: Tom Lane
Date:
Subject: Re: How to get the name of a table's primary key?