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

Re: Changing the Primary Key Column

From: Michael Ewan <michael(dot)ewan(at)intel(dot)com>
To: pdxpug(at)postgresql(dot)org
Subject: Re: Changing the Primary Key Column
Date: 2011-02-24 00:16:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pdxpug

On 02/23/2011 04:12 PM, Rich Shepard wrote:
> 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. :-(

Yes that would be a good idea, and was implied in any suggestion of 
dropping tables.  ;-)
Just be advised, pg_dump dumps to a copy from stdin: format with tab 

In response to


pdxpug by date

Next:From: Tim BruceDate: 2011-02-24 00:21:21
Subject: Re: Changing the Primary Key Column
Previous:From: Rich ShepardDate: 2011-02-24 00:12:12
Subject: Re: Changing the Primary Key Column

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