Home > Database > Mysql Tutorial > Oracle的dbms_random各函数使用

Oracle的dbms_random各函数使用

WBOY
Release: 2016-06-07 17:26:55
Original
1181 people have browsed it

Oracle的dbms_random各函数使用 1、包定义: sqlgt;desc dbms_random Element Type ---------- --------- SEED PROCED

Oracle的dbms_random各函数使用

1、包定义:

sql>desc dbms_random

Element    Type

---------- ---------

SEED      PROCEDURE

VALUE      FUNCTION

NORMAL    FUNCTION

STRING    FUNCTION

INITIALIZE PROCEDURE

RANDOM    FUNCTION

TERMINATE  PROCEDURE

NUM_ARRAY  TYPE

2、使用举例:

a、value() 用于返回两个数值之间的随机数,,value(low,high)

SQL> select dbms_random.value() from dual;

DBMS_RANDOM.VALUE()  默认是从0到1间的数

-------------------

0.0536824248407651

SQL> select dbms_random.value(10,100) from dual;

DBMS_RANDOM.VALUE(10,100)

-------------------------

29.2420951206225

b、random() 返回的值介于2的31次方和-2的31次方之间的整形数值

SQL>  select dbms_random.random() from dual;

DBMS_RANDOM.RANDOM()

--------------------

2071097056

SQL>  select dbms_random.random() from dual;

DBMS_RANDOM.RANDOM()

--------------------

-1589187025

c、string('parameter',length)

SQL> select dbms_random.string('a',10) from dual;    --all返回不分大小写的字母字符串

DBMS_RANDOM.STRING('A',10)

--------------------------------------------------------------------------------

eDvKaqNWII

SQL> select dbms_random.string('u',10) from dual;  --upper返回大写字母字符串

DBMS_RANDOM.STRING('U',10)

--------------------------------------------------------------------------------

KPGNYTWDGA

SQL>  select dbms_random.string('l',10) from dual;  --little小写字母

DBMS_RANDOM.STRING('L',10)

--------------------------------------------------------------------------------

zehtdserww

SQL> select dbms_random.string('x',10) from dual;  ---大写字母加数字

DBMS_RANDOM.STRING('X',10)

--------------------------------------------------------------------------------

3Z7DBA4S8I

SQL> select dbms_random.string('p',10) from dual;  --print 所有可以打印的字符

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template