Unique value over different servers

Started by Per-Olof Petterssonalmost 25 years ago2 messagesgeneral
Jump to latest
#1Per-Olof Pettersson
pgsql@peope.net

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

#2Einar Karttunen
ekarttun@cs.Helsinki.FI
In reply to: Per-Olof Pettersson (#1)
Re: Unique value over different servers

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