Skip site navigation (1) Skip section navigation (2)

Re: BUG #1079: ALTER TABLE does not add foreign key

From: Richard Huxton <dev(at)archonet(dot)com>
To: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
Cc: vova(at)densoft(dot)com(dot)ua
Subject: Re: BUG #1079: ALTER TABLE does not add foreign key
Date: 2004-02-11 18:44:56
Message-ID: 200402111844.56307.dev@archonet.com (view raw or flat)
Thread:
Lists: pgsql-bugs
On Wednesday 11 February 2004 17:29, PostgreSQL Bugs List wrote:
> The following bug has been logged online:
>
> Bug reference:      1079
> Logged by:          Vladimir Sitarchuk
> Email address:      vova(at)densoft(dot)com(dot)ua
>
> PostgreSQL version: 7.3
> Operating system:   Red Hat 9
> Description:        ALTER TABLE does not add foreign key
>
> Details:
> ALTER TABLE tablename ADD COLUMN columnname INT CONSTRAIN cntrname
> REFERENCES tablename2(col)
> adds the column But it does not add the foreign key constrain.

Perhaps the manual should be clearer on this.

You can add a foreign key with something like (example from manual):
ALTER TABLE distributors ADD CONSTRAINT distfk FOREIGN KEY (address) 
REFERENCES addresses(address) MATCH FULL;
-- 
  Richard Huxton
  Archonet Ltd

In response to

pgsql-bugs by date

Next:From: Tom LaneDate: 2004-02-11 19:17:44
Subject: Re: BUG #1079: ALTER TABLE does not add foreign key
Previous:From: PostgreSQL Bugs ListDate: 2004-02-11 17:29:30
Subject: BUG #1079: ALTER TABLE does not add foreign key

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group