Re: Asserting existing key to be primary

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Asserting existing key to be primary
Дата
Msg-id 26174.1092425056@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Asserting existing key to be primary  (Chris Browne <cbbrowne@acm.org>)
Список pgsql-hackers
Chris Browne <cbbrowne@acm.org> writes:
> I have a table that has a candidate primary key (e.g. - unique, not
> null) that I wish to actually assert _is_ a primary key.

> Is there a way to do that without too much (mwahahhaha! fiddling with
> pg_class!!!) trickery?

Why don't you just ALTER TABLE ADD PRIMARY KEY and then drop the
existing unique constraint?

You could probably fool with pg_constraint and pg_index to manually
transform the unique constraint into a pkey constraint, but the odds
of messing it up seem to outweigh the possible time savings.
        regards, tom lane


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

Предыдущее
От: Gaetano Mendola
Дата:
Сообщение: Re: hot spare / log shipping work on
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Referencing OLD/NEW Rows on Trigger Definition