-
Website
http://awads.net/wp/ -
Original page
http://awads.net/wp/2005/07/28/random-string-generator/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
jgarry
3 comments · 1 points
-
Andy C
22 comments · 47 points
-
dahowlett
1 comment · 2 points
-
Don Seiler
9 comments · 1 points
-
davidhaimes
4 comments · 3 points
-
-
Popular Threads
http://thinkoracle.blogspot.com/2005/05/random-...
I could not understand your problem. However, here are some clarifications about the package
DBMS_RANDOMwhich I'm sure you already know, but does not hurt to add them here for future reference:The package
DBMS\_RANDOMis only available in Oracle version 8 and above.If you want to encrypt sensitive data, then you should use the built-in package
DBMS\_OBFUSCATION\_TOOLKIT, notDBMS\_RANDOM.For an analysis of
DBMS\_RANDOM, how it works and the quality of the generated random numbers or strings, I suggest this article.The following functions are not documented in Oracle 8i and Oracle 9i
DBMS\_RANDOM's documentation, but they are in Oracle 10g's:NORMAL,VALUEandSTRING. A look at the source code ofDBMS\_RANDOMreveals these hidden and useful functions.Hi Eddie,
I can't really figure out what's the use for SEED procedure here. Can you explain further?
As I execute the code below, it give me the same result.
<pre>
BEGIN
dbms_random.seed(1234535678);
dbms_output.put_line('Random1: '||dbms_random.value);
END;
Random1: .62004818671882084550610341425311827476
</pre>
edcas, the seed is needed to generate the random number or string. The seed can be a number or a string. If you do not initialize the generator by explicitly calling the seed procedure, a default seed is used, in that case, it is equal to:
<pre>
TO_CHAR(SYSDATE,'MM-DD-YYYY HH24:MI:SS') ||
USER || USERENV('SESSIONID')
</pre>
So, if you do not seed, and then call dbms_random.value, chances are you will not get the same random value.
The dbms_random package specification says: If this package is seeded twice with the same seed, then accessed in the same way, it will produce the same results in both cases.
So, your observation is correct, given the same seed over and over again, you will get the same result each time you execute the same dbms_random procedure.
How can a seed be used? well, one example is when you want to generate a random password. You would seed the generator with the username, so distinct usernames will have distinct random passwords, but same usernames will have the same random password since the seed (username) is the same.