Re: unique ID - globally
Date: 2000/02/18
Message-ID: <b2lrask845l1mda03mdf7lkkk85pbtaebr_at_4ax.com>#1/1
A copy of this was sent to S P Arif Sahari Wibowo <arifsaha_at_null.net> (if that email address didn't require changing) On Fri, 18 Feb 2000 16:35:48 -0600, you wrote:
>Hi!
>
>Do you know how to make a unique ID for primary key - globally?
>
>It seems like people agree that the best unique ID locally - in once
>server - is using the sequence, right? But how about unique ID from
>multiple server, that not necessarily have good connection between them?
>
>What I am thinking of is concatenate the sequence number from one server
>with one number that uniq to a server, IP number probably? Well, how
>oracle can find out its own IP number?
>
>Other idea?
>
>Thank you.
A common way is to do something like:
create sequence my_seq start with 1 increment by 100000;
at site 1.
create sequence my_seq start with 2 increment by 200000;
at site 2.
and so on. If you have less then 100,000 sites -- this'll work and since sequences can generate numbers upto 28 digits long -- you don't have to worry about "wasting" a couple of numbers. very doubtful you would run out.
In oracle8i, release 8.1 there is a new function:
ops$tkyte_at_8i> select sys_guid() from dual;
SYS_GUID()
60DA948240D75882E034080020A767E0
It generates and returns a globally unique identifier (RAW value) made up of 16 bytes. On most platforms, the generated identifier consists of a host identifier and a process or thread identifier of the process or thread invoking the function, and a nonrepeating value (sequence of bytes) for that process or thread.
-- See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'... Current article is "Part I of V, Autonomous Transactions" updated June 21'st Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA Opinions are mine and do not necessarily reflect those of Oracle CorporationReceived on Fri Feb 18 2000 - 00:00:00 CET