Обсуждение: BUG #1079: ALTER TABLE does not add foreign key

Поиск
Список
Период
Сортировка

BUG #1079: ALTER TABLE does not add foreign key

От
"PostgreSQL Bugs List"
Дата:
The following bug has been logged online:

Bug reference:      1079
Logged by:          Vladimir Sitarchuk

Email address:      vova@densoft.com.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.

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

От
Richard Huxton
Дата:
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@densoft.com.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

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

От
Tom Lane
Дата:
"PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes:
> ALTER TABLE tablename ADD COLUMN columnname INT CONSTRAIN cntrname
> REFERENCES tablename2(col)
> adds the column But it does not add the foreign key constrain.

This was fixed as of 7.3.3.

            regards, tom lane