RAND (SYSFUN schema) scalar function
The RAND function returns a floating point value between 0 and 1. RAND is a non-deterministic function.
The schema is SYSFUN.
- An expression that returns a value of data type SMALLINT or INTEGER. The value must be between 0 and 2,147,483,647. The returned value is used as a seed value.
A specific seed value produces the same sequence of random numbers for a specific instance of a RAND function in a query each time the query is executed. The seed value is used only for the first invocation of an instance of the RAND function within a statement. If a seed value is not specified, a different sequence of random numbers is produced each time the query is executed within the same session. To produce a set of random numbers that varies from session to session, specify a random seed; for example, one that is based on the current time.
The RAND scalar function does not guarantee the uniqueness of the random numbers. Use the GENERATE_UNIQUE scalar function to generate a series unique numbers.
The RAND function relies on the random number facilities of the host operating system. The random number facility of each host might vary in factors such as the number of potential distinct values and the quality of the randomness. For these reasons, the output of this function is not suitable as a source of randomness in a cryptographic system.
The data type of the result is double-precision floating point. If the argument is null, the result is the null value. If either argument can be null, the result can be null. If either argument is null, the result is the null value.