Re: How to get the name of a table's primary key?

From: Christian von Kietzell <chris(at)gammu(dot)ath(dot)cx>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get the name of a table's primary key?
Date: 2002-03-16 19:46:12
Message-ID: 20020316204612.A8716@wh2-227.uni-magdeburg.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gammu(dot)ath(dot)cx
Jabber: cuboci(at)charente(dot)de

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-03-16 20:58:35 Re: How to get the name of a table's primary key?
Previous Message Jonathan Ellis 2002-03-16 19:42:57 locking problems