Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Good random number source in oracle
While you can do what you described, it will be a lot slower because of the work that the Oracle server will have to do to call the C function.
The DBMS_RANDOM package has been thoroughly tested and produces a good random distribution. I think that it should be adequate for most purposes. The one purpose for which it is not appropriate, though, is the generation of encryption keys.
Frank Hubeny <member_at_dBforums.com> writes:
> Others have discussed seed values for a random function.
>
> It is also important that the algorithm generating the random number is
> acceptable.
>
> Without passing judgment on dbms_random, one has the option of using the
> C functions "rand" or "random" as well.
>
> These functions are available in libc.so and some documentation on them
> is available through "man". To make them available in Oracle, do the
> following:
>
> (1) Create a library, such as TEST:ORACLE> create or replace library
> libc as '/usr/lib/libc.so.1';
> 2 /
>
> Library created.
>
> (3) Create a function to use "random" as follows: TEST:ORACLE>
> create or replace function random 2 return binary_integer 3 is
> external library LIBC name "random" 4 calling standard c
> parameters(return long);
> 4 /
>
> Function created.
>
> (5) Experiment with the new function: TEST:ORACLE> select random
> from dual;
>
> RANDOM
> ----------
> 1027100827
>
>
>
>
>
>
> --
> Posted via dBforums
> http://dbforums.com
-- Thanks, Rick Rick Wessman Server Security Group Oracle Corporation rwessman_at_us.oracle.com The opinions expressed above are mine and do not necessarily reflect those of Oracle Corporation.Received on Fri May 04 2001 - 11:29:37 CDT
![]() |
![]() |