Re: Adding Foreign Key Constraint To Existing Table

Поиск
Список
Период
Сортировка
От Thom Brown
Тема Re: Adding Foreign Key Constraint To Existing Table
Дата
Msg-id BANLkTim+uRVdaJf1ap_NXfKm3MM+9dPPcA@mail.gmail.com
обсуждение исходный текст
Ответ на Adding Foreign Key Constraint To Existing Table  (Rich Shepard <rshepard@appl-ecosys.com>)
Ответы Re: Adding Foreign Key Constraint To Existing Table
Список pgsql-general
On 1 July 2011 22:00, Rich Shepard <rshepard@appl-ecosys.com> wrote:
>  I've examined the 9.0 manual page on alter table without seeing how to add
> a foreign key constraint to a column.
>
>  I needed to make changes on a couple of existing tables which could be
> accomplished only by dropping the foreign key constraint. That, and changing
> the table structure, column names, and column types were successful. But, I
> am not seeing the proper syntax to add a foreign key constraint back to the
> two affected tables.

By the way, rather than dropping the foreign key then recreating it,
you could always do this:

ALTER TABLE tablename DISABLE TRIGGER ALL;

Then it would ignore the foreign key trigger and you could put in
mischievous values... but remember to enable it again (replace DISABLE
with ENABLE).  You'll have to be a superuser to do it though.

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

В списке pgsql-general по дате отправления:

Предыдущее
От: Rich Shepard
Дата:
Сообщение: Re: Adding Foreign Key Constraint To Existing Table
Следующее
От: Rich Shepard
Дата:
Сообщение: Re: Adding Foreign Key Constraint To Existing Table