Re: Changing primary keys - Mailing list pgsql-novice

From Richard Broersma Jr
Subject Re: Changing primary keys
Date
Msg-id 20060927200452.37095.qmail@web31801.mail.mud.yahoo.com
Whole thread Raw
In response to Changing primary keys  (Carol Cheung <cacheung@consumercontact.com>)
List 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 by date:

Previous
From: Carol Cheung
Date:
Subject: Changing primary keys
Next
From: "Brandon Aiken"
Date:
Subject: Re: Changing primary keys