Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: randomly generate unique key

RE: randomly generate unique key

From: Pardee, Roy E <roy.e.pardee_at_lmco.com>
Date: Fri, 30 May 2003 09:44:56 -0800
Message-ID: <F001.005A7161.20030530094456@fatcity.com>


There's an optional db package called dbms_random that you can use to get random numbers. Dig it:

http://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_datab ase_id=NOT&p_id=77326.1

There's also a sql function (in 9i only?) called sys_guid() that returns a globally unique identifier--big ugly things. See that at:

http://download-west.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/ functions122a.htm#84836

I think I'd try dbms_random first--keep using your sequence, but 'salt' the actual identifier by concatenating 3 or 4 random digits at the beginning or end of the sequence value. That way the sequence will guarantee uniqueness, but the numbers should not be guessable. Plus these would be numbers that human beings can reasonbly be expected to remember--I can't imagine asking people to remember the GUID I assign them...

HTH,
-Roy

Roy Pardee
Programmer/Analyst/DBA
SWFPAC Lockheed Martin IT
Extension 8487

-----Original Message-----

Sent: Friday, May 30, 2003 8:45 AM
To: Multiple recipients of list ORACLE-L

Hi List,

Originally, Our next generate directory group use sequence # to generate a unique key. (we can't use emplid or social s # as key, since students doesn't have emplid and some foreign students doesn't have ssn). That works fine until the policy changed, they need to publish the unique key which is trunk id. According to the developers, if publish those sequenced unique key, it will create some problems, since the community can guess the next sequence # and got unnecessary info associated with it. Now the question is how to create a random unique key? The idea is create a function call combine the 3 components (date, time, MAC address) to generate a random #. Does the date/time (client query system time)can always be unique or can be duplicated? Does someone has any idea or experience to generate those randomly unique key?

Any info would be helpful.

Thanks in advance,

Joan
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Joan Hsieh
  INET: joan.hsieh_at_tufts.edu

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Pardee, Roy E
  INET: roy.e.pardee_at_lmco.com
Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri May 30 2003 - 12:44:56 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US