Oracle DBMS_RANDOM Package to Generate Random Numbers, Strings

advertisements

_____________________________________________________________________________________________________________________

The Eucharistic Miracles of the World
Generate random decimal value
SQL> select dbms_random.value from dual;

     VALUE
----------
.969676006
Generate a random number between 1 and 1000


SQL> select trunc(dbms_random.value(1,1000)) from dual;

TRUNC(DBMS_RANDOM.VALUE(1,1000))
--------------------------------
                             231

Generate random number between 1 and 3

SQL> select trunc(dbms_random.value(1,3)) from dual;

TRUNC(DBMS_RANDOM.VALUE(1,3))
-----------------------------
                            1

SQL> select trunc(dbms_random.value(1,3)) from dual;

TRUNC(DBMS_RANDOM.VALUE(1,3))
-----------------------------
                            2
Generate Random string of length 5 and mixed case. First argument should be either A or a

SQL> SELECT DBMS_RANDOM.STRING('A', 5) ran_str from dual;

RAN_STR
----------
hXLQi

Generate Random string of length 5 and Lower case. First argument should be either L or l

SQL> SELECT DBMS_RANDOM.STRING('L', 5) ran_str from dual;

RAN_STR
----------
sxifw

Generate Random string of length 5 and Upper case. First argument should be either U or u

SQL>  SELECT DBMS_RANDOM.STRING('U', 5) ran_str from dual;

RAN_STR
----------
QKPHC

_____________________________________________________________________________________________________________________

Website Stats

0 comments:

Post a Comment

Labels

Oracle (629) Script (86) General (77) Unix (47) Blog (23) Technology (19) gadget (6) games (6) Business (3) OCI (3) SQL* Loader (3) Datapump (2)
 

acehints.com Copyright 2011-23 All Rights Reserved | Site Map | Contact | Disclaimer