Returns a pseudo-random UInt32 number, uniformly distributed among all UInt32 values.
Uses a linear congruential generator.
Syntax
rand([x])
Parameter
x — An expression that evaluates to any supported data type. The result value will be discarded, but if the function is called multiple times within a query, the expression itself can be used to bypass common subexpression elimination. Optional parameter.Return value
Example
SELECT rand(), rand(number) FROM numbers(2);
┌─rand()─────┬─rand(number)─┐ │ 3882830473 │ 2236253349 │ │ 4122795699 │ 3720179576 │ └────────────┴──────────────┘
Returns a pseudo-random UInt64 number, uniformly distributed among all UInt64 values.
Uses a linear congruential generator.
Syntax
rand64([x])
Parameter
x — An expression that evaluates to any supported data type. The result value will be discarded, but if the function is called multiple times within a query, the expression itself can be used to bypass common subexpression elimination. Optional parameter.Return value
Example
SELECT rand64(), rand64(number) FROM numbers(2);
┌─rand64()────────────┬─rand64(number)───────┐ │ 4216084906413806748 │ 17404981640646529534 │ │ 874879808660605772 │ 941470430861381566 │ └─────────────────────┴──────────────────────┘
Generates a constant column with random values.
Syntax
randConstant([x])
Parameter
x — An expression that evaluates to any supported data type. The result value will be discarded, but if the function is called multiple times within a query, the expression itself can be used to bypass common subexpression elimination. Optional parameter.Return value
Example
SELECT rand(), rand(1), rand(number), randConstant(), randConstant(1), randConstant(number) FROM numbers(3)
┌─rand()─────┬─rand(1)────┬─rand(number)─┬─randConstant()─┬─randConstant(1)─┬─randConstant(number)─┐ │ 1617218167 │ 3030783952 │ 3660442590 │ 3335999329 │ 1508515848 │ 1880875990 │ │ 432450540 │ 2987789840 │ 653572307 │ 3335999329 │ 1508515848 │ 1880875990 │ │ 3698169875 │ 79826010 │ 458167070 │ 3335999329 │ 1508515848 │ 1880875990 │ └────────────┴────────────┴──────────────┴────────────────┴─────────────────┴──────────────────────┘