Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways

Поиск
Список
Период
Сортировка
От Christoph Berg
Тема Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways
Дата
Msg-id 20190322083614.GA32388@msg.df7cb.de
обсуждение исходный текст
Ответ на BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways  (PG Bug reporting form <noreply@postgresql.org>)
Список pgsql-bugs
Re: PG Bug reporting form 2019-03-21 <15710-f52bad04543be4cb@postgresql.org>
> CREATE TABLE test (id SERIAL PRIMARY KEY);
> ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer UNIQUE;

As a workaround, you can name the constraint:

ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer CONSTRAINT id_unique UNIQUE;

Then it won't get added multiple times. (It will still be executed
once, though.)

Christoph


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