RE: Custom Sequence Generator

From: Mark W. Farnham <mwf_at_rsiz.com>
Date: Wed, 15 Oct 2014 22:36:26 -0400
Message-ID: <018901cfe8e9$fcb86280$f6292780$_at_rsiz.com>



Ah – Tim picked up that you want to limit this to 10 or 12 digits (as that is not an Oracle limitation of sequences).  

I highly recommend base 13, because then the universe is in your favor.  

9,999,999,999,999 (almost 10 trillion) converts to 576CC4158519 base 13 (so you can get plenty high with 12 digits if you only need billions)

54 base 10 is 42 base 13

54 is number of cards in a playing card deck if you count the jokers.  

This, of course, proves that the universe IS base 13 and that it is full of jokers, and this (combined with a toothbrush and a towel) will allow you to hitchhike around the galaxy in a panic free state.  

mwf  

From: oracle-l-bounce_at_freelists.org [mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Tim Gorman Sent: Wednesday, October 15, 2014 5:57 PM To: oracle-l_at_freelists.org; Ebadi, Abdul Subject: Re: Custom Sequence Generator  

Abdul,

It sounds like you feel you might run out of numbers generated using base-10 within 10-12 digits, right?

To "cram" more possible values into 12 digits, use a higher base, such as base16 (i.e. hexadecimal) or base64 (i.e. as used in Oracle ROWIDs, which use the ranges of "[A-Z][a-z][0-9]+-" as the values for each digit)?

Twelve digits in base10 gets you to 1 billion (i.e. 1,000,000,000,000) minus one. That's probably too small.

Twelve digits in base16 gets you to about 281.4 trillion or so. That might be a little better for you, and it would be relatively easy to code. Using one value at a rate of 1/sec should take about 8.9 million years to exhaust, which also means that using one value each micro-second should still take about 8.9 years to exhaust?

So, if that's not good enough, then twelve digits in base64 probably gets you to where you sound like you want to be. :-) Problem is, you'd almost certainly have to code your own base10-to-base64 and base64-to-base10 converters.

Hope this helps...

-Tim

On 10/15/14 14:28, Ebadi, Abdul wrote:

Hi,  

We have a need to generate a 10 or 12 digit unique key. Anyone have a quick function for this? For example: 435A24C1.  

We don’t want to use Oracle’s sequences as we are afraid we will run out of unique ones. We need billions of these keys.  

Thanks,

Abdul    

--

http://www.freelists.org/webpage/oracle-l Received on Thu Oct 16 2014 - 04:36:26 CEST

Original text of this message