The
DBMS_RANDOM
package provides a built-in random number generator.- May 25, 2004 Generating random numbers or strings is oft-times a necessity. Oracle provides a random number generator that is faster than writing your won random generation logic in PL/SQL, and can generate both character and alphanumeric strings. Perhaps it is time to learn more about the DBMSRANDOM package.
- Jan 24, 2017 Creating or modifying an Oracle Database user password can be done by using any standard password generator you can find on the WEB. But I wanted a password to comply to “ora12cstrongverifyfunction”, and this isn’t as easy to generate as you might expect. Though most generators provide options to include or exclude certain character groups,Read More.
This chapter contains the following topics:
- Operational notes
Jul 24, 2018 In this video, you’ll learn how to generate random alphanumeric characters in an SQL statement in Oracle SQL You can use Oracle SQL to generate random alphanumeric string values.
DBMSRANDOM.RANDOM produces integers in -2^^31, 2^^31). DBMSRANDOM.VALUE produces numbers in 0,1) with 38 digits of precision. DBMSRANDOM can be explicitly initialized, but does not need to be initialized before calling the random number generator. Oracle 10g introduced a number of functions that should be used in place of the RANDOM function. In Oracle 11gR1, the RANDOM function was deprecated in favour of these other functions. Generating Random Dates. There are no specific functions for generating random dates, but we can add random numbers to an existing date to make it random. A random date in what range? Is any valid date value acceptable so that a large fraction of the dates you generate will be B.C. And a relatively small fraction will be in the 20th or 21st century? Do you want the time component to be random as well or do you want the dates to be at midnight as in your example? – Justin Cave Jul 3 '13 at 14:07.
Note:
DBMS_RANDOM
is not intended for cryptography.Using DBMS_RANDOM
Operational notes
- The
RANDOM
function produces integers in the range [-2^^31, 2^^31). - The
VALUE
function produces numbers in the range [0,1) with 38 digits of precision.
DBMS_RANDOM
can be explicitly initialized but does not require initialization before a call to the random number generator. It automatically initializes with the date, user ID, and process ID if no explicit initialization is performed. Adobe acrobat 10 key generator.If this package is seeded twice with the same seed, then accessed in the same way, it produces the same result 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 an overload of
SEED
. To produce different output for every run, simply omit the seed call. Then the system chooses a suitable seed for you.Summary of DBMS_RANDOM subprograms
Table 6-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. | |
One version gets a random number greater than or equal to 0 and less than 1, with 38 digits to the right of the decimal point (38-digit precision). The other version gets a random Oracle Database number x , where x is greater than or equal to a specified lower limit and less than a specified higher limit. |
Note:
The INITIALIZE procedure, RANDOM function and TERMINATE procedure are deprecated. They are included in this release for legacy reasons only.Notes:
- The
PLS_INTEGER
andBINARY_INTEGER
data types are identical. This document usesBINARY_INTEGER
to indicate data types in reference information (such as for table types, record types, subprogram parameters, or subprogram return values), but may use either in discussion and examples. - The
INTEGER
andNUMBER(38)
data types are also identical. This document usesINTEGER
throughout.
INITIALIZE procedure
This procedure is deprecated. Although currently supported, it should not be used. It initializes the random number generator.
Parameters
Table 6-2 INITIALIZE procedure parameters
Parameter | Description |
---|---|
val | Seed number used to generate a random number |
Usage notes
This procedure is obsolete as it simply calls the SEED procedure.
NORMAL function
This function returns random numbers in a standard normal distribution.
Return value
The random number, a
NUMBER
valueRANDOM function
This procedure is deprecated. Although currently supported, it should not be used. It generates and returns a random number.
Return value
A random
BINARY_INTEGER
value greater than or equal to -power(2,31)
and less than power(2,31)
Usage notes
See the NORMAL function and the VALUE function.
SEED procedure
This procedure resets the seed used in generating a random number.
Parameters
Table 6-3 SEED procedure parameters
Parameter | Description |
---|---|
val | Seed number or string used to generate a random number |
Usage notes
The seed can be a string up to length 2000.
STRING function
This function generates and returns a random string.
Parameters
Table 6-4 STRING function parameters
Parameter | Description |
---|---|
opt | What the returning string looks like:
Otherwise the returning string is in uppercase alpha characters. |
len | Length of the returned string |
Return value
A
VARCHAR2
value with the random stringGenerate Random Key In Oracle Login
TERMINATE procedure
This procedure is deprecated. Although currently supported, it should not be used. It would be called when the user is finished with the package.
VALUE function
One version returns 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). The other version returns a random Oracle Database
NUMBER
value x
, where x
is greater than or equal to the specified low
value and less than the specified high
value.Parameters
Table 6-5 VALUE function parameters
Parameter | Description |
---|---|
low | Lower limit of the range in which to generate a random number |
high | Upper limit of the range in which to generate a random number |
Return value
A
NUMBER
value that is the generated random numberThe
DBMS_RANDOM
package provides a built-in random number generator. DBMS_RANDOM
is not intended for cryptography.This chapter contains the following topics:
- Security Model
- Operational Notes
Using DBMS_RANDOM
Security Model
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.Operational Notes
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, userid, 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.Summary of DBMS_RANDOM Subprograms
Table 75-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 | |
This 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), while the overloaded function gets a random Oracle number x, where x is greater than or equal to low and less than high |
Note:
The INITIALIZE Procedure, RANDOM Procedure and the TERMINATE Procedure are all obsolete and, while currently supported, are included in this release for legacy reasons only.INITIALIZE Procedure
This procedure initializes the generator (but see Usage Notes).
Syntax
Pragmas
Parameters
Table 75-2 INITIALIZE Procedure Parameters
Parameter | Description |
---|---|
val | The seed number used to generate a random number. |
Usage Notes
This procedure is obsolete as it simply calls the SEED Procedures.
NORMAL Function
This function returns random numbers in a standard normal distribution.
Syntax
Pragmas
Return Values
Table 75-3 NORMAL Procedure Parameters
Parameter | Description |
---|---|
number | Returns a random number. |
RANDOM Procedure
Black ops 2 for pc. This procedure generates a random number (but see Usage Notes).
Syntax
Pragmas
Return Values
Table 75-4 RANDOM Procedure Parameters
Parameter | Description |
---|---|
binary_integer A few Instructions about the Angry Birds Space Key Generator for PC and Crack Free Download: 1. It would be ideal if you take after the guidelines beneath the page to download Angry Birds Space Crack for Free. Angry birds space key code. | Returns a random integer greater or equal to -power(2,31) and less than power(2,31). |
Usage Notes
This procedure is obsolete and, although it is currently supported, it should not be used.
SEED Procedures
This procedure resets the seed.
Syntax
Pragmas
Parameters
Table 75-5 SEED Procedure Parameters
Parameter | Description |
---|---|
seed | Seed number or string used to generate a random number. |
Usage Notes
The seed can be a string up to length 2000.
STRING Function
This function gets a random string.
Syntax
Pragmas
Parameters
Table 75-6 STRING Function Parameters
Parameter | Description |
---|---|
opt | Specifies what the returning string looks like:
Otherwise the returning string is in uppercase alpha characters. |
len | The length of the returning string. |
Return Values
Table 75-7 STRING Function Return Values
Parameter | Description |
---|---|
VARCHAR2 | Returns a VARCHAR2 . |
TERMINATE Procedure
When you are finished with the package, call the TERMINATE procedure (but see Usage Notes)
Syntax
Usage Notes
This procedure performs no function and, although it is currently supported, it is obsolete and should not be used.
VALUE Functions
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
.Syntax
Generate Random Key In Oracle Number
Parameters
Table 75-8 VALUE Function Parameters
Parameter | Description |
---|---|
low | The lowest number in a range from which to generate a random number. The number generated may be equal to low. |
high | The highest number below which to generate a random number. The number generated will be less than high. |
Return Values
Table 75-9 VALUE Function Return Values
Parameter | Description |
---|---|
NUMBER | Returns an Oracle Number. |