The NORMAL function returns a random number that follows a standard normal distribution (with mean 0 and standard deviation 1).
NORMAL is often used to generate simulated test data, such as sampling performance metrics that follow a normal distribution or constructing statistically relevant test scenarios. If you only need uniformly distributed random numbers, use the VALUE function; if you need random integers within the range [-2^31, 2^31), use the RANDOM function.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this function.
Syntax
DBMS_RANDOM.NORMAL
RETURN NUMBER;
Return value
Parameter |
Description |
|---|---|
| number | A random number that follows a standard normal distribution, of type NUMBER. |
Considerations
NORMALgenerates a random number from a standard normal distribution by applying the Box-Muller transform to an internally generated uniform random number. Theoretically, its range is all real numbers, but most values lie within the interval [-3, 3].Each call to
NORMALadvances the internal random number sequence. To ensure reproducibility of results, set a fixed seed usingSEEDorINITIALIZE.
Examples
Generate a random number from a standard normal distribution.
obclient> SELECT DBMS_RANDOM.NORMAL FROM DUAL;
The result is as follows:
+------------------------------------------+
| DBMS_RANDOM.NORMAL |
+------------------------------------------+
| 1.28077954567105677709794954780170843821 |
+------------------------------------------+
1 row in set
Since the result of the random number varies with each execution, the values shown above are for illustrative purposes only.