oracle dbms_random

1.dbms_random.random

return equal to -power(2,31) and less than power(2,31)

SQL> select abs(dbms_random.random ) from dual;

ABS(DBMS_RANDOM.RANDOM)
-----------------------
             1149033468

2.DBMS_RANDOM.VALUE(low  IN  NUMBER,high IN  NUMBER)

SQL> select round(dbms_random.value(1,500) ) from dual;

ROUND(DBMS_RANDOM.VALUE(1,500))
-------------------------------
                            227

3.DBMS_RANDOM.STRING

STRING : This function gets a random string.
DBMS_RANDOM.STRING
   opt  IN  CHAR,
   len  IN  NUMBER)
  RETURN VARCHAR2;
 
'u', 'U' - returning string in uppercase alpha characters
'l', 'L' - returning string in lowercase alpha characters
'a', 'A' - returning string in mixed case alpha characters
'x', 'X' - returning string in uppercase alpha-numeric characters
'p', 'P' - returning string in any printable characters.

SQL> select dbms_random.STRING('L',15) from dual;

DBMS_RANDOM.STRING('L',15)
--------------------------------------------------------------------------------
vonhtvmqqychsvf

SQL> select dbms_random.STRING('U',10) from dual;

DBMS_RANDOM.STRING('U',10)
--------------------------------------------------------------------------------
OUGJGUXJSU

SQL> select dbms_random.STRING('A',10) from dual;

DBMS_RANDOM.STRING('A',10)
--------------------------------------------------------------------------------
IMAkRtkbka

SQL> select dbms_random.STRING('X',20) from dual;

DBMS_RANDOM.STRING('X',20)
--------------------------------------------------------------------------------
RBENBEDHO83X43U0WUOW

SQL> select dbms_random.STRING('P',20) from dual
  2  ;

DBMS_RANDOM.STRING('P',20)
--------------------------------------------------------------------------------
Ycg>H.A@.[X%"5rr4\rv

 

上一篇:oracle常用字符函数


下一篇:有关Sql中时间范围的问题