Re: Add Foreign Keys To Table

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Rich Shepard'" <rshepard(at)appl-ecosys(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Add Foreign Keys To Table
Date: 2011-07-07 20:31:56
Message-ID: 01c301cc3ce4$eaa34380$bfe9ca80$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----Original Message-----
From: Rich Shepard [mailto:rshepard(at)appl-ecosys(dot)com]
Sent: Thursday, July 07, 2011 4:05 PM
To: David Johnston
Subject: RE: [GENERAL] Add Foreign Keys To Table

On Thu, 7 Jul 2011, David Johnston wrote:

> To do what you want to do look up "CREATE INDEX" in the documentation.

David,

Now I understand this.

> You probably need to add "BOTH" fields to "station_information" and
> then say something like.
>
> FOREIGN KEY (field1, field2) REFERENCES table (field1, field2) ...

And this would be for each of the two added fields? Same syntax? I've not
used this approach before.

Thanks,

Rich

>>>>>>>>>>>>>>>>>>>>>>>>>

You would HAVE to do it at the TABLE level since a column-level constraint
can only reference that single column.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2011-07-07 21:12:41 Re: Add Foreign Keys To Table
Previous Message Guillaume Lelarge 2011-07-07 20:26:45 Re: DELETE taking too much memory