From: | Darren Ferguson <darren(at)crystalballinc(dot)com> |
---|---|
To: | Christian von Kietzell <chris(at)gammu(dot)ath(dot)cx> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How to get the name of a table's primary key? |
Date: | 2002-03-15 16:47:27 |
Message-ID: | Pine.LNX.4.10.10203151145450.12478-100000@thread.crystalballinc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
HTH
Darren Ferguson
On Fri, 15 Mar 2002, Christian von Kietzell wrote:
> Hi,
>
> I'm sorry if this is a stupid question, but how can I obtain the name
> of a primary key of a given table? Suppose I've got a simple table
> like this:
>
> create table foo (
> foo_pkey int primary key,
> foo_data varchar(50)
> );
>
> In a programme I only know the table name "foo" and want to get the
> name of the primary key.
> Any help on this?
>
> Cheers,
> Chris
>
> --
> Christian von Kietzell
> mailto: chris(at)gammu(dot)ath(dot)cx
> Jabber: cuboci(at)charente(dot)de
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
From | Date | Subject | |
---|---|---|---|
Next Message | Jan Wieck | 2002-03-15 17:31:42 | Re: Drop all databases objects except the database |
Previous Message | Cornelia Boenigk | 2002-03-15 16:42:49 | How to catch notify messages with PHP |