Re: Changing primary keys

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Changing primary keys
Дата
Msg-id 20060927200452.37095.qmail@web31801.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Changing primary keys  (Carol Cheung <cacheung@consumercontact.com>)
Список pgsql-novice
> The table 'house' was created with the below code (partial)
>
> CREATE TABLE house (
>    house_id bigserial unique not null,
>    phone bigint not null,
>    address varchar(75) not null,
>    primary key(phone, address)
> );
>
> My question is how can I switch the primary key from (phone, address) to
> house_id, now that the table is created and records have been inserted.

http://www.postgresql.org/docs/8.1/interactive/sql-altertable.html


You will need to determine the name of your primary key constraint so that you can drop it using
the alter table syntax.  I believe that "$> \d+ house" will do this for you.

Next you can create the new primary key constraint following the sytanx in the link.

Regards,

Richard Broersma Jr.

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

Предыдущее
От: Carol Cheung
Дата:
Сообщение: Changing primary keys
Следующее
От: "Brandon Aiken"
Дата:
Сообщение: Re: Changing primary keys