Add Primary Key to a Table

From: "Tom Haddon" <tom(at)betterhealthfoundation(dot)org>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Add Primary Key to a Table
Date: 2002-08-02 23:16:36
Message-ID: NEBBIHDGCLBEJMPFAMLACELLCHAA.tom@betterhealthfoundation.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Folks,

I'm trying to use the ALTER TABLE command to add a primary key to a table.

The command I am using is:

ALTER TABLE "agency_contact_info" ADD CONSTRAINT "agency_contact_info_pkey"
PRIMARY KEY ("id");

I get a message saying "ALTER TABLE / ADD CONSTRAINT not implemented for
that constraint type". Is this a bug, or am I doing something wrong?

The reason I am trying to do this is that I want to split a table with a
large number of fields up into a few tables with a sub-set of fields from
the original table, linked by FOREIGN KEY on "id". I had thought the best
way to do this was to use SELECT INTO and then try to alter the tables to
include PRIMARY and FOREIGN keys where applicable. Is there a better way to
do this?

Thanks, Tom

_______________________________
Tom Haddon
IT Director
The Better Health Foundation
414 Thirteenth Street, Suite 450
Oakland, CA 94612
(510) 444-5096
www.betterhealthfoundation.org
_______________________________

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-08-02 23:19:51 Re: Add Primary Key to a Table
Previous Message Josh Berkus 2002-08-02 23:14:48 Re: What about this?