oracle dbms_random

Posted A running snail,little step ev

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 dbms_random的主要内容,如果未能解决你的问题,请参考以下文章

oracle使用DBMS_RANDOM包生成随机数据

oracle中使用DBMS_RANDOM去产生随机数

oracle中使用DBMS_RANDOM去产生随机数

oracle系统包——dbms_random用法及order by 小结(转)

Oracle dbms_random

DBMS_RANDOM.VALUE返回的值等于HIGH值