The DBMS_RANDOM
package provides a built-in random number generator. DBMS_RANDOM
is not intended for cryptography.
This chapter contains the following topics:
Deprecated Subprograms
Security Model
Operational Notes
Note:
Oracle recommends that you do not use deprecated procedures in new applications. Support for deprecated features is for backward compatibility only.The following subprograms are deprecated with Oracle Database 11g:
This package should be installed as SYS
. By default, the package is initialized with the current user name, current time down to the second, and the current session. Oracle recommends that users who need to execute this package should be given EXECUTE
privilege explicitly and should not rely on PUBLIC
EXECUTE
privilege.
DBMS_RANDOM.RANDOM
produces integers in [-2^^31, 2^^31).
DBMS_RANDOM.VALUE
produces numbers in [0,1) with 38 digits of precision.
DBMS_RANDOM
can be explicitly initialized, but does not need to be initialized before calling the random number generator. It will automatically initialize with the date, user ID, and process ID if no explicit initialization is performed.
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.
In some cases, such as when testing, you may want the sequence of random numbers to be the same on every run. In that case, you seed the generator with a constant value by calling one of the overloads of DBMS_RANDOM.SEED
. To produce different output for every run, simply to omit the call to "Seed" and the system will choose a suitable seed for you.
Table 108-1 DBMS_RANDOM Package Subprograms
Subprogram | Description |
---|---|
Initializes the package with a seed value |
|
Returns random numbers in a normal distribution |
|
Generates a random number |
|
Resets the seed |
|
Gets a random string |
|
Terminates package |
|
Gets a random number, greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal (38-digit precision), while the overloaded function gets a random Oracle number x, where x is greater than or equal to |
This procedure initializes the generator.
Note:
This procedure is deprecated with Release 11gR1 and, although currently supported, it should not be used.This procedure is obsolete as it simply calls the SEED Procedures.
This procedure generates a random number.
Note:
This procedure is deprecated with Release 11gR1 and, although currently supported, it should not be used.This function gets a random string.
Table 108-6 STRING Function Parameters
Parameter | Description |
---|---|
|
Specifies what the returning string looks like:
Otherwise the returning string is in uppercase alpha characters. |
|
Length of the returning string |
When you are finished with the package, call the TERMINATE
procedure.
Note:
This procedure is deprecated with Release 11gR1 and, although currently supported, it should not be used.The basic function gets a random number, greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal (38-digit precision). Alternatively, you can get a random Oracle number x, where x is greater than or equal to low
and less than high
.
DBMS_RANDOM.VALUE RETURN NUMBER; DBMS_RANDOM.VALUE( low IN NUMBER, high IN NUMBER) RETURN NUMBER;