Oracle dbms_random
Oracle dbms_random
Introduce several commonly used functions to generate 0-1 decimals (default)
SQL > select dbms_random.valuefrom dual
VALUE
-
. 932351752
Note: the result can be processed by trunc and round functions
Generate a number within the specified range
FUNCTION VALUE RETURNS NUMBER
Argument Name Type In/Out Default?
-
LOW NUMBER IN
HIGH NUMBER IN
SQL > select dbms_random.value (235.48) from dual
DBMS_RANDOM.VALUE (23,048)
-
23.1991482
Note: the result can be processed by trunc and round functions
A random number string of length 20
SQL > select length (cast (dbms_random.valueas varchar2 (1024) from dual
LENGTH (CAST (DBMS_RANDOM.VALUEASVARCHAR2 (1024)
thirty-nine
It means that only 38 placeholders have numbers after the decimal point.
SQL > select substr (cast (dbms_random.valueas varchar2 (38)), 3Jing 20) from dual
SUBSTR (CAST (DBMS_RANDOM.VALUEASVARCHAR2)
-
52633757378080443317
Random number of normal distribution
Select dbms_random.normal from dual
Random string
Select dbms_random.string (opt, length) fromdual
Available values for opt are as follows:
'upright grammar': uppercase letters
'l 'er': lowercase letters.
'a small letter': upper and lowercase letters
'x numbers, uppercase letters
'pendant dint': printable characters
SQL > select dbms_random.string ('Utopia 10) from dual
DBMS_RANDOM.STRING ('Utopia 10)
- -
DTKOJUGGHI
Summary: random dates and random strings can be realized through dbms_random, and those with random changes can be converted using this function.