Skip site navigation (1) Skip section navigation (2)

Re: Changing the Primary Key Column

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pdxpug(at)postgresql(dot)org
Subject: Re: Changing the Primary Key Column
Date: 2011-02-24 00:12:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pdxpug
On Wed, 23 Feb 2011, Michael Ewan wrote:

> Maybe someone else has a better answer but in my experience you have to
> drop the table to change the PK. You can add/drop other indexes or FK.
> How about leaving the synthetic PK and adding an extra index for your
> other key. Doing that also gets you away from any duplicate primary key
> errors. Although Josh Berkus will probably slap me silly for ever
> suggesting a synthetic key.


   Joe Celko doesn't like synthetic keys, either.

   I suppose what I need to do is dump the table to a .sql file and make
changes there. If I drop the table I lose all the hours of work getting data
in there. :-(



Richard B. Shepard, Ph.D.          |   The Plain English Science Consultant
Applied Ecosystem Services, Inc.   |   Helping Ensure Our Clients' Futures
<>     Voice: 503-667-4517      Fax: 503-667-8863

In response to


pdxpug by date

Next:From: Michael EwanDate: 2011-02-24 00:16:34
Subject: Re: Changing the Primary Key Column
Previous:From: Michael EwanDate: 2011-02-24 00:06:48
Subject: Re: Changing the Primary Key Column

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group