Thread: Unique value over different servers

Unique value over different servers

From
Per-Olof Pettersson
Date:
I have two databases on two different servers.

I'd like to make a field that will be unique on both servers.

Is this possible. How do I accompish that. Is oid a good value to use?
Is there a function for it?

Best regards
Per-Olof Pettersson


Re: Unique value over different servers

From
Einar Karttunen
Date:
On Mon, 28 May 2001, Per-Olof Pettersson wrote:

> I have two databases on two different servers.
>
> I'd like to make a field that will be unique on both servers.
>
> Is this possible. How do I accompish that. Is oid a good value to use?
> Is there a function for it?
>
oid is not the way to do it. Currently there is IMHO no easy and good way
to implement it. If you don't mind using a very non-portable and bad way
of doing it you could for example create the following sequences:
in db1:
CREATE SEQUENCE unique_values_in_both_dbs INCREMENT 2 MINVALUE 1;
in db2:
CREATE SEQUENCE unique_values_in_both_dbs INCREMENT 2 MINVALUE 2;

But this not not a solution you should use if you have an alternative


Einar Karttunen