Skip to main content
All functions in this section accept zero or one arguments. The only use of the argument (if provided) is to prevent common subexpression elimination such that two different executions within a row of the same random function return different random values. Related content
The random numbers are generated by non-cryptographic algorithms.
The documentation below is generated from the system.functions system table.

fuzzBits

Introduced in: v20.5.0 Flips the bits of the input string s, with probability p for each bit. Syntax
Arguments
  • s — String or FixedString to perform bit fuzzing on String or FixedString
  • p — Probability of flipping each bit as a number between 0.0 and 1.0 Float*
Returned value Returns a Fuzzed string with same type as s. String or FixedString Examples Usage example
Query
Response

rand

Introduced in: v1.1.0 Returns a random UInt32 number with uniform distribution. Uses a linear congruential generator with an initial state obtained from the system, which means that while it appears random, it’s not truly random and can be predictable if the initial state is known. For scenarios where true randomness is crucial, consider using alternative methods like system-level calls or integrating with external libraries. Syntax
Aliases: rand32 Arguments
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random number of type UInt32. UInt32 Examples Usage example
Query
Response

rand64

Introduced in: v1.1.0 Returns a random distributed UInt64 number with uniform distribution. Uses a linear congruential generator with an initial state obtained from the system, which means that while it appears random, it’s not truly random and can be predictable if the initial state is known. For scenarios where true randomness is crucial, consider using alternative methods like system-level calls or integrating with external libraries. Syntax
Arguments
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random UInt64 number with uniform distribution. UInt64 Examples Usage example
Query
Response

randBernoulli

Introduced in: v22.10.0 Returns a random Float64 number drawn from a Bernoulli distribution. Syntax
Arguments
  • probability — The probability of success as a value between 0 and 1. Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified Bernoulli distribution. UInt64 Examples Usage example
Query
Response

randBinomial

Introduced in: v22.10.0 Returns a random Float64 number drawn from a binomial distribution. Syntax
Arguments
  • experiments — The number of experiments UInt64
  • probability — The probability of success in each experiment as a value between 0 and 1 Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified binomial distribution. UInt64 Examples Usage example
Query
Response

randCanonical

Introduced in: v22.11.0 Returns a random distributed Float64 number with uniform distribution between 0 (inclusive) and 1 (exclusive). Syntax
Arguments
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number. Float64 Examples Usage example
Query
Response

randChiSquared

Introduced in: v22.10.0 Returns a random Float64 number drawn from a chi-square distribution. Syntax
Arguments
  • degree_of_freedom — Degrees of freedom. Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified chi-square distribution. Float64 Examples Usage example
Query
Response

randConstant

Introduced in: v1.1.0 Generates a single random value that remains constant across all rows in the current query execution. This function:
  • Returns the same random value for every row within a single query
  • Produces different values across separate query executions
It is useful for applying consistent random seeds or identifiers across all rows in a dataset Syntax
Arguments
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a column of type UInt32 containing the same random value in each row. UInt32 Examples Basic usage
Query
Response
Usage with parameter
Query
Response

randExponential

Introduced in: v22.10.0 Returns a random Float64 number drawn from an exponential distribution. Syntax
Arguments
  • lambda — Rate parameter or lambda value of the distribution Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified exponential distribution. Float64 Examples Usage example
Query
Response

randFisherF

Introduced in: v22.10.0 Returns a random Float64 number drawn from an F-distribution. Syntax
Arguments
  • d1 — d1 degree of freedom in X = (S1 / d1) / (S2 / d2). Float64
  • d2 — d2 degree of freedom in X = (S1 / d1) / (S2 / d2). Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified F-distribution Float64 Examples Usage example
Query
Response

randLogNormal

Introduced in: v22.10.0 Returns a random Float64 number drawn from a log-normal distribution. Syntax
Arguments
  • mean — The mean value of distribution. Float64
  • stddev — The standard deviation of the distribution. Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified log-normal distribution. Float64 Examples Usage example
Query
Response

randNegativeBinomial

Introduced in: v22.10.0 Returns a random Float64 number drawn from a negative binomial distribution. Syntax
Arguments
  • experiments — The number of experiments. UInt64
  • probabilityThe probability of failure in each experiment as a value between 0and1. [Float64`](/reference/data-types/float)
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified negative binomial distribution UInt64 Examples Usage example
Query
Response

randNormal

Introduced in: v22.10.0 Returns a random Float64 number drawn from a normal distribution. Syntax
Arguments
  • mean — The mean value of distribution Float64
  • stddev — The standard deviation of the distribution Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified normal distribution. Float64 Examples Usage example
Query
Response

randPoisson

Introduced in: v22.10.0 Returns a random Float64 number drawn from a Poisson distribution distribution. Syntax
Arguments
  • n — The mean number of occurrences. UInt64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified Poisson distribution. UInt64 Examples Usage example
Query
Response

randStudentT

Introduced in: v22.10.0 Returns a random Float64 number drawn from a Student’s t-distribution. Syntax
Arguments
  • degree_of_freedom — Degrees of freedom. Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random Float64 number drawn from the specified Student’s t-distribution. Float64 Examples Usage example
Query
Response

randUniform

Introduced in: v22.10.0 Returns a random Float64 number drawn uniformly from the interval [min,max][\min, \max]. Syntax
Arguments
  • min — Left boundary of the range (inclusive). Float64
  • max — Right boundary of the range (inclusive). Float64
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a random number drawn uniformly from the interval formed by min and max. Float64 Examples Usage example
Query
Response

randomFixedString

Introduced in: v20.5.0 Generates a random fixed-size string with the specified number of character. The returned characters are not necessarily ASCII characters, i.e. they may not be printable. Syntax
Arguments
  • length — Length of the string in bytes. UInt*
Returned value Returns a string filled with random bytes. FixedString Examples Usage example
Query
Response

randomPrintableASCII

Introduced in: v20.1.0 Generates a random ASCII string with the specified number of characters. If you pass length < 0, the behavior of the function is undefined. Syntax
Arguments
  • length — String length in bytes. (U)Int*
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a string with a random set of ASCII printable characters. String Examples Usage example
Query
Response

randomString

Introduced in: v20.5.0 Generates a random string with the specified number of characters. The returned characters are not necessarily ASCII characters, i.e. they may not be printable. Syntax
Arguments
  • length — Length of the string in bytes. (U)Int*
  • x — Optional and ignored. The only purpose of the argument is to prevent common subexpression elimination when the same function call is used multiple times in a query. Any
Returned value Returns a string filled with random bytes. String Examples Usage example
Query
Response

randomStringUTF8

Introduced in: v20.5.0 Generates a random UTF-8 string with the specified number of codepoints. No codepoints from unassigned planes (planes 4 to 13) are returned. It is still possible that the client interacting with ClickHouse server is not able to display the produced UTF-8 string correctly. Syntax
Arguments
  • length — Length of the string in code points. (U)Int*
Returned value Returns a string filled with random UTF-8 codepoints. String Examples Usage example
Query
Response
Last modified on June 19, 2026