Re: combining db's- importing primary keys

From: Bob Gobeille <bob(dot)gobeille(at)hp(dot)com>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: combining db's- importing primary keys
Date: 2009-07-29 14:19:07
Message-ID: DC7E876B-454F-4EC3-AB62-240475B00B74@hp.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jul 29, 2009, at 7:02 AM, Jasen Betts wrote:

> On 2009-07-27, Bob Gobeille <bob(dot)gobeille(at)hp(dot)com> wrote:
>> I would like to combine multiple databases (same schema) into one
>> master db. Does anyone know how I can reconcile all my primary and
>> foreign keys to maintain referential integrity.
>
> prefix them all with something that's unique to their source database.
>
> easy to say, hard to do.

I can't believe this didn't occur to me. All my primary keys are
bigint's, but I could add a second field, a unique server number or
name, and change my primary (and foreign) keys to the two column
combination. This would make it easy for new db's but I need to give
some thought to see if there will be any hiccups migrating all the db's.

Many thanks Jasen.

Bob

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Emanuel Calvo Franco 2009-07-29 14:21:06 Problems compiling contribs in Open Solaris
Previous Message Tom Lane 2009-07-29 14:17:53 Re: Clients disconnect but query still runs