Search notes:

Oracle: DBMS_RANDOM

dbms_random is a random number generator.
dbms_random is not suitable for Cryptography purposes, instead, the random* functions that are found in the dbms_crypto package should be used.

Procedures and functions

normal Returns numbers whose distribution is standard normal.
seed Sets or resets the random generator's seed. By default, the package is seeded with the user's name, current time (accurate down to a second) and the session.
string Returns a text with a given characteristic
value Returns a number between 0 and 1 or a choosable lower and upper limit.
initialize Deprecated, calls seed.
random Deprecated
terminate Deprecated

NORMAL

create table tq84_random_normal (
  val number
);

insert into tq84_random_normal
  select
    dbms_random.normal
  from
    dual
  connect by level <= 10000;

select
   to_char(avg     (val), '90.9999') avg_val,
   to_char(median  (val), '90.9999') median_val,
   to_char(variance(val), '90.9999') var_val,
   to_char(var_pop (val), '90.9999') var_pop_val,
   to_char(var_samp(val), '90.9999') var_samp_val,
   --
   to_char(min     (val), '90.9999') min_val,
   to_char(max     (val), '90.9999') max_val
from
  tq84_random_normal;

drop table tq84_random_normal purge;

VALUE

dbms_random.value returns a number between 0 and 1.
dbms_random.value(low, high) returns a number between low and high.
create table tq84_random_value (
  val number
);

insert into tq84_random_value
select
  dbms_random.value(8, 12)
from
  dual
connect by
  level <= 100;

select
  min(val) min_val,
  max(val) max_val,
  avg(val) avg_val
from
  tq84_random_value;

drop table tq84_random_value purge;

SEED

Seeding dbms_random with a given value causes it to produce the same series of «random» data if a given sequence of functions is called.
SQL> exec dbms_random.seed(20)
SQL> select trunc(dbms_random.value(1,10000)) from dual;
3936
SQL> select dbms_random.string('U', 5) from dual;
LZZZJ

TERMINATE

--
-- dbms_random.terminate() is terminated (that is: deprecated) with Oracle 11R1
--

See also

Using dbms_random to
Oracle DBMS PL/SQL packages
dbms_random used in a simple dummy data generator.

Index