DBMS_RANDOM

Related Interfaces

Table 1 provides all interfaces supported by the DBMS_RANDOM package.

Table 1 DBMS_RANDOM interface parameters

API

Description

DBMS_RANDOM.SEED

Sets a seed for a random number.

DBMS_RANDOM.VALUE

Generates a random number between a specified low and a specified high.

The only requirement is that the parameter type is NUMERIC regardless of the right and left bound values.

Example

Generate a random number between 0 and 1:

1
SELECT DBMS_RANDOM.VALUE(0,1);

To get a random integer in a range, use a low and high as the lower and upper bounds. The result will be greater than or equal to low, but less than high. To get an integer ranging from 0 to 99, run the following command:

1
SELECT TRUNC(DBMS_RANDOM.VALUE(0,100));