C/C++教程

oracle dbms_random

本文主要是介绍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的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!