From: | Richard Broersma Jr <rabroersma(at)yahoo(dot)com> |
---|---|
To: | Carol Cheung <cacheung(at)consumercontact(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Changing primary keys |
Date: | 2006-09-27 20:04:52 |
Message-ID: | 20060927200452.37095.qmail@web31801.mail.mud.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Brandon Aiken | 2006-09-27 20:14:22 | Re: Changing primary keys |
Previous Message | Carol Cheung | 2006-09-27 19:54:59 | Changing primary keys |