编程知识 cdmana.com

Oracle database uses function DBMS_RANDOM to generate random number method

Foreword:
It has been really painful recently. I have been traveling and working overtime endlessly. Recently, everyone must be careful about changing jobs this year.In the past few days, because I want to create a customer-oriented demonstration environment for the leaders, I found that many colleagues in the test group do not know how Oracle generates random numbers.Reminds me of memories, hahaha.
1. Generate decimals from 0 to 1:

select dbms_random.value from dual;

2. Generate decimals within the specified range (0~100)

select dbms_random.value(0,100) from dual;

3. Integer in the specified range (0~100)

select trunc(dbms_random.value(0,100) from dual;)

4. Generate a random number string of length 10

select substr(cast(dbms_random.value as varchar2(38)),0,10) from dual;

5. Normal distribution of random numbers

select dbms_random.normal from dual;

6. Random string

select dbms_random.string('x',3span>) from dual;

版权声明
本文为[Starry Flow >_<]所创,转载请带上原文链接,感谢
https://cdmana.com/2022/266/202209230844378517.html

Scroll to Top