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

Поиск
Список
Период
Сортировка
От richard coleman
Тема Why isn't there a IF NOT EXISTS clause on constraint creation?
Дата
Msg-id CAGA3vBvFJuPjPK6K2L7htCmRKHGm4vm7YPpEsZaynP30Ps+UxQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: Why isn't there a IF NOT EXISTS clause on constraint creation?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-admin
I find myself having to check a couple of hundred tables and add the primary keys back in, if they don't exist.

While there's a IF NOT EXISTS clause on the DROP statement to drop a constraint, like a primary key, inexplicably there isn't one on the ALTER TABLE statement that creates them.

The internet is littered with people asking about this, some going back years.  The responses range from manually checking first, using a DROP IF EXISTS statement first, to writing various blocks of PL/pgSQL code.

Why doesn't ALTER TABLE ...  ADD CONSTRAINT not come with an ALTER TABLE ... ADD CONSTRAINT IF NOT EXISTS variant?

Could one be added?

Just wondering, 
rik.

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

Предыдущее
От: Nikhil Shetty
Дата:
Сообщение: Logical Replication hung: logical_decoding_work_mem over utilised
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Why isn't there a IF NOT EXISTS clause on constraint creation?