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: alpine.LNX.2.00.1102231610090.17955@salmo.appl-ecosys.com (view raw or flat)
Thread:
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.

Michael,

   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. :-(

Thanks,

Rich

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

In response to

Responses

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-2014 The PostgreSQL Global Development Group