Take a record from the table, generate random numbers and random strings

xiaoxiao2021-03-06  87

1. Take the record from the table

Select * from (select * from staff order by dbms_random.random)

WHERE ROWNUM <4

Represents 3 records from the STAFF table

2, generate random number

Select dbms_random.random from dual;

Generate a random number of any size

SELECT ABS (MOD (DBMS_Random.random, 100)) from DUAL;

Generate a random number within a 100

SELECT TRUNC (100 900 * dbms_random.value) from dual;

Generate a random number between 100 ~ 1000

Select dbms_random.value from dual;

Generate a random number between 0 ~ 1

Select dbms_random.value (10, 20) from Dual;

Generate a random number between 10 ~ 20

Select dbms_random.normal from dual;

Normal function returns a set of normal distributions. This normal distribution standard deviation is 1, the expected value is 0. 68% of the value returned by this function is between -1 and 1, 95% between -2 and 2, 99% is between -3 and 3.

3, generate random strings

Select dbms_random.string from dual;

Returns a random string of 60 characters long. (Unsucaching success)

Select dbms_random.string ('p', 20) from DUAL;

The first parameter P represents the Printable, ie the string is composed of any printed characters to indicate the second parameter indicates that the return string length is returned.

转载请注明原文地址:https://www.9cbs.com/read-122596.html

New Post(0)