Recreate primary key without dropping foreign keys?

Поиск
Список
Период
Сортировка
От Chris Ernst
Тема Recreate primary key without dropping foreign keys?
Дата
Msg-id 4F8B6AA1.1040709@zvelo.com
обсуждение исходный текст
Ответы Re: Recreate primary key without dropping foreign keys?
Список pgsql-admin
Hi all,

In PostgreSQL 9.1.3, I have a few fairly large tables with bloated
primary key indexes.  I'm trying to replace them using newly created
unique indexes as outlined in the docs.  Something like:

CREATE UNIQUE INDEX CONCURRENTLY dist_id_temp_idx ON distributors (dist_id);
ALTER TABLE distributors DROP CONSTRAINT distributors_pkey,
    ADD CONSTRAINT distributors_pkey PRIMARY KEY USING INDEX
dist_id_temp_idx;

However, the initial drop of the primary key constraint fails because
there are a whole bunch of foreign keys depending on it.

I've done some searching and haven't found a workable solution.  Is
there any way to swap in the new index for the primary key constraint
without dropping all dependent foreign keys?  Or am I pretty much stuck
with dropping and recreating all of the foreign keys?

Thanks in advance.

Chris Ernst
Data Operations Engineer
Zvelo, Inc.
http://zvelo.com/

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

Предыдущее
От: Rural Hunter
Дата:
Сообщение: Re: invalid byte sequence for encoding "UTF8": 0xf481 - how could this happen?
Следующее
От: Frank Lanitz
Дата:
Сообщение: Re: Recreate primary key without dropping foreign keys?