Re: Converting non-null unique idx to pkey

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Converting non-null unique idx to pkey
Дата
Msg-id 2467.1187761230@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Converting non-null unique idx to pkey  ("Ed L." <pgsql@bluepolka.net>)
Ответы Re: Converting non-null unique idx to pkey
Список pgsql-general
"Ed L." <pgsql@bluepolka.net> writes:
> Are there
> are any known or obvious gotchas associated with transforming a
> unique index on a non null column into a primary key via this
> sql?

> update pg_index
> set indisprimary = 't'
> where indexrelid = <my non-null unique index oid>

The problem with that is there won't be any pg_constraint entry,
nor any pg_depend entries linking to/from the constraint.

I don't offhand know which bits of logic look at indisprimary
and which pay attention to the pg_constraint entry (and 7.4 is
probably different from current sources on the point anyway).
Things could get a bit weird though, particularly for pg_dump.

Of course, you could gin up the required pg_constraint and pg_depend
entries by hand too, but it's a lot more complex than the above.

If you really wanna do this I'd strongly recommend experimenting
in a scratch database.

            regards, tom lane

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

Предыдущее
От: "Robin Helgelin"
Дата:
Сообщение: Re: history table
Следующее
От: "Frank Millman"
Дата:
Сообщение: Problem with UPDATE and UNIQUE