Functions for generating random numbers

**Returned value**

Returns a random Float64 number drawn from the specified normal distribution. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT randNormal(10, 2) FROM numbers(5)
```

```
┌──randNormal(10, 2)─┐
│ 13.389228911709653 │
│  8.622949707401295 │
│ 10.801887062682981 │
│ 4.5220192605895315 │
│ 10.901239123982567 │
└────────────────────┘
```

## randPoisson[​](#randPoisson "Direct link to randPoisson")

Introduced in: v22.10.0

Returns a random Float64 number drawn from a [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution) distribution.

**Syntax**

```
randPoisson(n[, x])
```

**Arguments**

- `n` — The mean number of occurrences. [`UInt64`](/docs/sql-reference/data-types/int-uint)
- `x` — Optional and ignored. The only purpose of the argument is to prevent [common subexpression elimination](/docs/sql-reference/functions/overview#common-subexpression-elimination) when the same function call is used multiple times in a query. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a random Float64 number drawn from the specified Poisson distribution. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT randPoisson(10) FROM numbers(5)
```

```
┌─randPoisson(10)─┐
│               8 │
│               8 │
│               7 │
│              10 │
│               6 │
└─────────────────┘
```

## randStudentT[​](#randStudentT "Direct link to randStudentT")

Introduced in: v22.10.0

Returns a random Float64 number drawn from a [Student's t-distribution](https://en.wikipedia.org/wiki/Student%27s_t-distribution).

**Syntax**

```
randStudentT(degree_of_freedom[, x])
```

**Arguments**

- `degree_of_freedom` — Degrees of freedom. [`Float64`](/docs/sql-reference/data-types/float)
- `x` — Optional and ignored. The only purpose of the argument is to prevent [common subexpression elimination](/docs/sql-reference/functions/overview#common-subexpression-elimination) when the same function call is used multiple times in a query. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a random Float64 number drawn from the specified Student's t-distribution. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT randStudentT(10) FROM numbers(5)
```

```
┌─────randStudentT(10)─┐
│   1.2217309938538725 │
│   1.7941971681200541 │
│ -0.28192176076784664 │
│   0.2508897721303792 │
│  -2.7858432909761186 │
└──────────────────────┘
```

## randUniform[​](#randUniform "Direct link to randUniform")

Introduced in: v22.10.0

Returns a random Float64 number drawn uniformly from the interval [min⁡,max⁡][\min, \max][min,max].

**Syntax**

```
randUniform(min, max[, x])
```

**Arguments**

- `min` — Left boundary of the range (inclusive). [`Float64`](/docs/sql-reference/data-types/float)
- `max` — Right boundary of the range (inclusive). [`Float64`](/docs/sql-reference/data-types/float)
- `x` — Optional and ignored. The only purpose of the argument is to prevent [common subexpression elimination](/docs/sql-reference/functions/overview#common-subexpression-elimination) when the same function call is used multiple times in a query. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a random number drawn uniformly from the interval formed by `min` and `max`. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT randUniform(5.5, 10) FROM numbers(5)
```

```
┌─randUniform(5.5, 10)─┐
│    8.094978491443102 │
│   7.3181248914450885 │
│    7.177741903868262 │
│    6.483347380953762 │
│    6.122286382885112 │
└──────────────────────┘
```

## randomFixedString[​](#randomFixedString "Direct link to 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**

```
randomFixedString(length)
```

**Arguments**

- `length` — Length of the string in bytes. [`UInt*`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns a string filled with random bytes. [`FixedString`](/docs/sql-reference/data-types/fixedstring)

**Examples**

**Usage example**

```
SELECT randomFixedString(13) AS rnd, toTypeName(rnd)
```

```
┌─rnd──────┬─toTypeName(randomFixedString(13))─┐
│ j▒h㋖HɨZ'▒ │ FixedString(13)                 │
└──────────┴───────────────────────────────────┘
```

## randomPrintableASCII[​](#randomPrintableASCII "Direct link to randomPrintableASCII")

Introduced in: v20.1.0

Generates a random [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) string with the specified number of characters.

If you pass `length < 0`, the behavior of the function is undefined.

**Syntax**

```
randomPrintableASCII(length[, x])
```

**Arguments**

- `length` — String length in bytes. [`(U)Int*`](/docs/sql-reference/data-types/int-uint)
- `x` — Optional and ignored. The only purpose of the argument is to prevent [common subexpression elimination](/docs/sql-reference/functions/overview#common-subexpression-elimination) when the same function call is used multiple times in a query. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a string with a random set of ASCII printable characters. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT number, randomPrintableASCII(30) AS str, length(str) FROM system.numbers LIMIT 3
```

```
┌─number─┬─str────────────────────────────┬─length(randomPrintableASCII(30))─┐
│      0 │ SuiCOSTvC0csfABSw=UcSzp2.`rv8x │                               30 │
│      1 │ 1Ag NlJ &RCN:*>HVPG;PE-nO"SUFD │                               30 │
│      2 │ /"+<"with:=LjJ Vm!c&hI*m#XTfzz │                               30 │
└────────┴────────────────────────────────┴──────────────────────────────────┘
```

## randomString[​](#randomString "Direct link to 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**

```
randomString(length[, x])
```

**Arguments**

- `length` — Length of the string in bytes. [`(U)Int*`](/docs/sql-reference/data-types/int-uint)
- `x` — Optional and ignored. The only purpose of the argument is to prevent [common subexpression elimination](/docs/sql-reference/functions/overview#common-subexpression-elimination) when the same function call is used multiple times in a query. [`Any`](/docs/sql-reference/data-types)

**Returned value**

Returns a string filled with random bytes. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT randomString(5) AS str FROM numbers(2)
```

```
���
�v6B�
```

## randomStringUTF8[​](#randomStringUTF8 "Direct link to randomStringUTF8")

Introduced in: v20.5.0

Generates a random [UTF-8](https://en.wikipedia.org/wiki/UTF-8) string with the specified number of codepoints.
No codepoints from unassigned [planes](https://en.wikipedia.org/wiki/Plane_(Unicode)) (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**

```
randomStringUTF8(length)
```

**Arguments**

- `length` — Length of the string in code points. [`(U)Int*`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns a string filled with random UTF-8 codepoints. [`String`](/docs/sql-reference/data-types/string)

**Examples**

**Usage example**

```
SELECT randomStringUTF8(13)
```

```
┌─randomStringUTF8(13)─┐
│ 𘤗𙉝д兠庇󡅴󱱎󦐪􂕌𔊹𓰛       │
└──────────────────────┘
```