Re: Why isn't there a IF NOT EXISTS clause on constraint creation?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Why isn't there a IF NOT EXISTS clause on constraint creation?
Дата
Msg-id 226806.1693430777@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Why isn't there a IF NOT EXISTS clause on constraint creation?  (richard coleman <rcoleman.ascentgl@gmail.com>)
Ответы Re: Why isn't there a IF NOT EXISTS clause on constraint creation?  (richard coleman <rcoleman.ascentgl@gmail.com>)
Список pgsql-admin
richard coleman <rcoleman.ascentgl@gmail.com> writes:
> Why doesn't ALTER TABLE ...  ADD CONSTRAINT not come with an ALTER TABLE
> ... ADD CONSTRAINT IF NOT EXISTS variant?

There's a general allergy in this project to CREATE IF NOT EXISTS,
because it's a foot-gun.  If the command succeeds, you know that
an object (constraint or whatever) by that name exists, but you
have no right to assume anything whatsoever about its properties.

CREATE OR REPLACE semantics are a lot less squishy.  Would a
command of that form solve your problem?  (I'm not sure about
a pleasing way to write that within ALTER TABLE, but this gripe
is about semantics not syntax.)

            regards, tom lane



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

Предыдущее
От: richard coleman
Дата:
Сообщение: Why isn't there a IF NOT EXISTS clause on constraint creation?
Следующее
От: richard coleman
Дата:
Сообщение: Re: Why isn't there a IF NOT EXISTS clause on constraint creation?