Re: ALTER TABLE table DROP CONSTRAINT problem

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ALTER TABLE table DROP CONSTRAINT problem
Дата
Msg-id 18726.1020377734@sss.pgh.pa.us
обсуждение исходный текст
Ответ на ALTER TABLE table DROP CONSTRAINT problem  (Lewis Bergman <lbergman@[nospam] abi.tconline.net>)
Список pgsql-novice
Lewis Bergman <lbergman@[nospam]abi.tconline.net> writes:
> I am trying to drop a constraint that was set up by this SQL
> ALTER TABLE customer_main ADD CONSTRAINT cust_main_agent
>   FOREIGN KEY ( agent )
>    REFERENCES customer_main ( id )
>     NOT DEFERRABLE;

> So I do this:
> ALTER TABLE customer_main DROP CONSTRAINT cust_main_agent RESTRICT;
> And get this error:
> ERROR:  ALTER TABLE / DROP CONSTRAINT: cust_main_agent does not exist

AFAIK, the current implementation of DROP CONSTRAINT only supports
dropping CHECK constraints; it gives you that error because it doesn't
find anything about cust_main_agent in the check-constraint table.

You can manually drop a foreign-key constraint by dropping the three or
so triggers that implement it.  I forget the details but they're in the
list archives.

There will probably be a cleaner way to do it in a release or two...

            regards, tom lane

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

Предыдущее
От: Terrence Brannon
Дата:
Сообщение: Re: non-root installation of Postgresql?
Следующее
От: "Josh Berkus"
Дата:
Сообщение: Re: root of parent-child table with NOT NULL