in the The dbms_random package in Oracle encapsulates a number of functions that generate random numbers and random strings, which are commonly used in the following two:
Dbms_random. VALUE function
This function is used to produce a random number in two ways:
1. Produces a random number of 1-bit precision between 0 and 1 (0 and 38 not included), with the syntax:
RETURN number;
This usage does not include parameters.
2. Produces a random number of the precision of the range within the specified scope , the syntax is:
inch Number inch Number RETURN number;
This usage consists of two parameters, the parameter low is used to specify the lower bound of the random number to be generated, the parameter high specifies the upper bound, and the generated random. Note that the generated random number may be equal to the lower limit, but is definitely less than the upper limit, or "low<= random number .
For example: to produce a number between 1 and 100, you can write this: Dbms_random. VALUE (1,100)
Dbms_random. STRING function
The function produces a random string with the following syntax:
inch CHAR,lenin numberRETURNVARCHAR2;
The parameter len Specifies the length of the generated string.
The parameter opt specifies the style of the resulting string, the allowable value and the meaning of the representation as shown in the following table:
For example, to produce a string of length 6 that includes only uppercase letters, you can write: Dbms_random. STRING (' U ', 6)
Attached: pseudo random number and random seed
The first thing to declare is that the computer does not produce an absolute random number, and the computer can only produce "pseudo-random numbers". In fact, an absolute random random number is only an ideal random number, and even if the computer develops, it will not produce a random number of absolute random numbers. A computer can only generate a relative random number, or pseudo-random number.
The so-called random number generator is a certain algorithm to the pre-selected random seed to do a complex operation, with the resulting results to approximate the simulation of a complete random number, this random number is called pseudo-random number. Pseudo-random numbers are selected from a finite set of numbers in the same probability. The selected number is not completely random, but from a practical point of view, its randomness is sufficient. The selection of pseudo-random numbers starts with random seeds, so the selection of random seeds is very important in order to ensure that the pseudo-random numbers are sufficiently "random" for each given. If the random seed is the same, then the random number generated by the same random number generator will be the same. In general, we use parameters associated with the system time as random seeds.
Reprinted from: http://www.cnblogs.com/lgzslf/archive/2008/11/29/1343685.html
add: SQL Server generates random code
Generate Numbers plus letters: Select Left (Newid (), 6)
function of generating random numbers in Oracle (reprint)