Re: Add Foreign Keys To Table

From: Alan Hodgson <ahodgson(at)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Add Foreign Keys To Table
Date: 2011-07-07 18:19:56
Message-ID: 201107071119.56980.ahodgson@simkin.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On July 7, 2011 10:40:11 AM Rich Shepard wrote:
> alter table station_information add column sta_type varchar(50)
> unique not null references station_type(sta_type);
> NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index
> "station_information_sta_type_key" for table "station_information"
> ERROR: there is no unique constraint matching given keys for referenced
> table "station_type"
> Reading the alter table document page for 9.x does not show me what I'm
> doing incorrectly.

You need a unique index on station_type.sta_type

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message French, Martin 2011-07-07 18:54:08 Re: [PERFORM] DELETE taking too much memory
Previous Message Rich Shepard 2011-07-07 17:40:11 Add Foreign Keys To Table