> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-3a82795f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 무작위 수를 생성하는 데 사용되는 함수 문서

# 무작위 수를 생성하는 함수

이 섹션의 모든 함수는 인수를 0개 또는 1개 받습니다. 인수(제공된 경우)의 유일한 용도는 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하여, 같은 행에서 동일한 무작위 함수가 두 번 실행되더라도 서로 다른 무작위 값을 반환하게 하는 것입니다.

관련 콘텐츠

* 가이드: [ClickHouse에서 무작위 데이터 생성하기](/ko/guides/clickhouse/data-modelling/generating-test-data)
* 블로그: [ClickHouse에서 무작위 데이터 생성하기](https://clickhouse.com/blog/generating-random-test-distribution-data-for-clickhouse)

<Note>
  무작위 수는 암호학적으로 안전하지 않은 알고리즘으로 생성됩니다.
</Note>

<Note>
  아래 문서는 `system.functions` 시스템 테이블에서 생성됩니다.
</Note>

{/*AUTOGENERATED_START*/}

<div id="fuzzBits">
  ## fuzzBits
</div>

도입 버전: v20.5.0

입력 문자열 `s`의 각 비트를 확률 `p`에 따라 반전합니다.

**구문**

```sql theme={null}
fuzzBits(s, p)
```

**인수**

* `s` — [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)에 대해 비트 퍼징을 수행할 `String` 또는 `FixedString`
* `p` — 각 비트를 뒤집을 확률로, `0.0`에서 `1.0` 사이의 숫자 [`Float*`](/ko/reference/data-types/float)

**반환 값**

`s`와 동일한 타입의 퍼징된 문자열을 반환합니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT fuzzBits(materialize('abacaba'), 0.1)
FROM numbers(3)
```

```response title=Response theme={null}
┌─fuzzBits(materialize('abacaba'), 0.1)─┐
│ abaaaja                               │
│ a*cjab+                               │
│ aeca2A                                │
└───────────────────────────────────────┘
```

<div id="rand">
  ## rand
</div>

도입 버전: v1.1.0

균등 분포를 따르는 임의의 `UInt32` 값을 반환합니다.

시스템에서 얻은 초기 상태를 사용하는 선형 합동 생성기를 사용하므로, 겉보기에는 무작위처럼 보이지만 실제로는 진정한 무작위가 아니며 초기 상태를 알고 있으면 예측할 수 있습니다.
진정한 무작위성이 중요한 경우에는 시스템 수준 호출이나 외부 라이브러리 연동과 같은 다른 방법의 사용을 고려하십시오.

**구문**

```sql theme={null}
rand([x])
```

**별칭**: `rand32`

**인수**

* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출이 하나의 쿼리에서 여러 번 사용될 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

`UInt32` 타입의 난수를 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT rand();
```

```response title=Response theme={null}
1569354847
```

<div id="rand64">
  ## rand64
</div>

도입 버전: v1.1.0

균등 분포를 따르는 임의의 `UInt64` 값을 반환합니다.

시스템에서 얻은 초기 상태를 사용하는 선형 합동 생성기를 사용합니다. 따라서 무작위처럼 보이지만, 실제로는 진정한 무작위는 아니며 초기 상태를 알면 예측할 수 있습니다.
진정한 무작위성이 중요한 경우에는 시스템 수준 호출을 사용하거나 외부 라이브러리를 연동하는 등의 대체 방법을 고려하십시오.

**구문**

```sql theme={null}
rand64([x])
```

**인수**

* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

균등 분포를 따르는 무작위 `UInt64` 값을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT rand64();
```

```response title=Response theme={null}
15030268859237645412
```

<div id="randBernoulli">
  ## randBernoulli
</div>

도입된 버전: v22.10.0

[베르누이 분포](https://en.wikipedia.org/wiki/Bernoulli_distribution)에서 생성된 임의의 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randBernoulli(probability[, x])
```

**인수**

* `probability` — `0`과 `1` 사이의 값으로 지정한 성공 확률입니다. [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 베르누이 분포에서 추출한 임의의 Float64 값을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randBernoulli(.75) FROM numbers(5)
```

```response title=Response theme={null}
┌─randBernoulli(0.75)─┐
│                   1 │
│                   1 │
│                   0 │
│                   1 │
│                   1 │
└─────────────────────┘
```

<div id="randBinomial">
  ## randBinomial
</div>

도입 버전: v22.10.0

[이항 분포](https://en.wikipedia.org/wiki/Binomial_distribution)에서 생성된 무작위 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randBinomial(experiments, probability[, x])
```

**인수**

* `experiments` — 실험 횟수 [`UInt64`](/ko/reference/data-types/int-uint)
* `probability` — 각 실험에서 성공할 확률을 나타내는 `0`과 `1` 사이의 값입니다 [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)을 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 이항 분포에서 추출된 무작위 Float64 숫자를 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randBinomial(100, .75) FROM numbers(5)
```

```response title=Response theme={null}
┌─randBinomial(100, 0.75)─┐
│                      74 │
│                      78 │
│                      76 │
│                      77 │
│                      80 │
└─────────────────────────┘
```

<div id="randCanonical">
  ## randCanonical
</div>

도입 버전: v22.11.0

`0`(포함) 이상 `1`(미포함) 미만 범위에서 균등 분포를 따르는 무작위 `Float64` 값을 반환합니다.

**구문**

```sql theme={null}
randCanonical([x])
```

**인수**

* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)가 일어나지 않도록 하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

무작위 `Float64` 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randCanonical();
```

```response title=Response theme={null}
0.345217890123456
```

<div id="randChiSquared">
  ## randChiSquared
</div>

도입 버전: v22.10.0

[카이제곱 분포](https://en.wikipedia.org/wiki/Chi-squared_distribution)를 따르는 무작위 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randChiSquared(degree_of_freedom[, x])
```

**인수**

* `degree_of_freedom` — 자유도입니다. [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 카이제곱 분포를 따르는 무작위 Float64 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randChiSquared(10) FROM numbers(5)
```

```response title=Response theme={null}
┌─randChiSquared(10)─┐
│ 10.015463656521543 │
│  9.621799919882768 │
│   2.71785015634699 │
│ 11.128188665931908 │
│  4.902063104425469 │
└────────────────────┘
```

<div id="randConstant">
  ## randConstant
</div>

도입 버전: v1.1.0

현재 쿼리 실행의 모든 행에서 동일하게 유지되는 단일 랜덤 값을 생성합니다.

이 함수의 특징은 다음과 같습니다:

* 단일 쿼리 내의 모든 행에 동일한 랜덤 값을 반환합니다
* 별도의 쿼리 실행마다 서로 다른 값을 생성합니다

데이터셋의 모든 행에 일관된 랜덤 시드 또는 식별자를 적용할 때 유용합니다

**구문**

```sql theme={null}
randConstant([x])
```

**인수**

* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 쿼리에서 동일한 함수 호출을 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

각 행에 동일한 난수 값이 들어 있는 `UInt32` 타입의 컬럼을 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT randConstant() AS random_value;
```

```response title=Response theme={null}
| random_value |
|--------------|
| 1234567890   |
```

**매개변수 사용**

```sql title=Query theme={null}
SELECT randConstant(10) AS random_value;
```

```response title=Response theme={null}
| random_value |
|--------------|
| 9876543210   |
```

<div id="randExponential">
  ## randExponential
</div>

도입 버전: v22.10.0

[지수 분포](https://en.wikipedia.org/wiki/Exponential_distribution)를 따르는 무작위 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randExponential(lambda[, x])
```

**인수**

* `lambda` — 분포의 비율 매개변수 또는 람다 값 [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 지수 분포를 따르는 임의의 Float64 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randExponential(1/10) FROM numbers(5)
```

```response title=Response theme={null}
┌─randExponential(divide(1, 10))─┐
│              44.71628934340778 │
│              4.211013337903262 │
│             10.809402553207766 │
│              15.63959406553284 │
│             1.8148392319860158 │
└────────────────────────────────┘
```

<div id="randFisherF">
  ## randFisherF
</div>

도입 버전: v22.10.0

[F-분포](https://en.wikipedia.org/wiki/F-distribution)를 따르는 임의의 Float64 수를 반환합니다.

**구문**

```sql theme={null}
randFisherF(d1, d2[, x])
```

**인수**

* `d1` — `X = (S1 / d1) / (S2 / d2)`에서의 d1 자유도입니다. [`Float64`](/ko/reference/data-types/float)
* `d2` — `X = (S1 / d1) / (S2 / d2)`에서의 d2 자유도입니다. [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 F-분포에서 추출된 임의의 Float64 숫자를 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randFisherF(10, 3) FROM numbers(5)
```

```response title=Response theme={null}
┌─randFisherF(10, 20)─┐
│  0.7204609609506184 │
│  0.9926258472572916 │
│  1.4010752726735863 │
│ 0.34928401507025556 │
│  1.8216216009473598 │
└─────────────────────┘
```

<div id="randLogNormal">
  ## randLogNormal
</div>

도입 버전: v22.10.0

[로그 정규 분포](https://en.wikipedia.org/wiki/Log-normal_distribution)를 따르는 임의의 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randLogNormal(mean, stddev[, x])
```

**인수**

* `mean` — 분포의 평균값입니다. [`Float64`](/ko/reference/data-types/float)
* `stddev` — 분포의 표준편차입니다. [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출이 하나의 쿼리에서 여러 번 사용될 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 로그 정규분포를 따르는 임의의 Float64 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randLogNormal(100, 5) FROM numbers(5)
```

```response title=Response theme={null}
┌─randLogNormal(100, 5)─┐
│  1.295699673937363e48 │
│  9.719869109186684e39 │
│  6.110868203189557e42 │
│  9.912675872925529e39 │
│ 2.3564708490552458e42 │
└───────────────────────┘
```

<div id="randNegativeBinomial">
  ## randNegativeBinomial
</div>

도입 버전: v22.10.0

[음이항 분포](https://en.wikipedia.org/wiki/Negative_binomial_distribution)를 따르는 무작위 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randNegativeBinomial(experiments, probability[, x])
```

**인수**

* `experiments` — 실험 횟수입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `probability` — `각 실험에서 실패할 확률로, `0`과`1`사이의 값입니다. [`Float64\`]\(/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출이 하나의 쿼리에서 여러 번 사용될 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)을 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 음이항 분포에서 추출한 임의의 Float64 값을 반환합니다 [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randNegativeBinomial(100, .75) FROM numbers(5)
```

```response title=Response theme={null}
┌─randNegativeBinomial(100, 0.75)─┐
│                              33 │
│                              32 │
│                              39 │
│                              40 │
│                              50 │
└─────────────────────────────────┘
```

<div id="randNormal">
  ## randNormal
</div>

도입 버전: v22.10.0

[정규 분포](https://en.wikipedia.org/wiki/Normal_distribution)를 따르는 무작위 `Float64` 값을 반환합니다.

**구문**

```sql theme={null}
randNormal(mean, stddev[, x])
```

**인수**

* `mean` — 분포의 평균값 [`Float64`](/ko/reference/data-types/float)
* `stddev` — 분포의 표준편차 [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출이 하나의 쿼리에서 여러 번 사용될 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)가 수행되지 않도록 하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 정규 분포에서 추출된 임의의 Float64 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randNormal(10, 2) FROM numbers(5)
```

```response title=Response theme={null}
┌──randNormal(10, 2)─┐
│ 13.389228911709653 │
│  8.622949707401295 │
│ 10.801887062682981 │
│ 4.5220192605895315 │
│ 10.901239123982567 │
└────────────────────┘
```

<div id="randPoisson">
  ## randPoisson
</div>

도입 버전: v22.10.0

[포아송 분포](https://en.wikipedia.org/wiki/Poisson_distribution)를 따르는 임의의 Float64 숫자를 반환합니다.

**구문**

```sql theme={null}
randPoisson(n[, x])
```

**인수**

* `n` — 평균 발생 횟수입니다. [`UInt64`](/ko/reference/data-types/int-uint)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출이 하나의 쿼리에서 여러 번 사용될 때 [공통 부분 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 포아송 분포에서 추출된 무작위 Float64 값을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randPoisson(10) FROM numbers(5)
```

```response title=Response theme={null}
┌─randPoisson(10)─┐
│               8 │
│               8 │
│               7 │
│              10 │
│               6 │
└─────────────────┘
```

<div id="randStudentT">
  ## randStudentT
</div>

도입 버전: v22.10.0

[Student's t-distribution](https://en.wikipedia.org/wiki/Student%27s_t-distribution)을 따르는 임의의 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randStudentT(degree_of_freedom[, x])
```

**인수**

* `degree_of_freedom` — 자유도입니다. [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 부분 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

지정된 Student's t-분포에서 추출된 무작위 `Float64` 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randStudentT(10) FROM numbers(5)
```

```response title=Response theme={null}
┌─────randStudentT(10)─┐
│   1.2217309938538725 │
│   1.7941971681200541 │
│ -0.28192176076784664 │
│   0.2508897721303792 │
│  -2.7858432909761186 │
└──────────────────────┘
```

<div id="randUniform">
  ## randUniform
</div>

도입 버전: v22.10.0

구간 $[\min, \max]$에서 균등하게 추출된 무작위 Float64 값을 반환합니다.

**구문**

```sql theme={null}
randUniform(min, max[, x])
```

**인수**

* `min` — 범위의 왼쪽 경계값입니다(포함). [`Float64`](/ko/reference/data-types/float)
* `max` — 범위의 오른쪽 경계값입니다(포함). [`Float64`](/ko/reference/data-types/float)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 부분 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)를 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

`min`과 `max` 사이의 인터벌에서 균등하게 추출한 난수를 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randUniform(5.5, 10) FROM numbers(5)
```

```response title=Response theme={null}
┌─randUniform(5.5, 10)─┐
│    8.094978491443102 │
│   7.3181248914450885 │
│    7.177741903868262 │
│    6.483347380953762 │
│    6.122286382885112 │
└──────────────────────┘
```

<div id="randomFixedString">
  ## randomFixedString
</div>

도입 버전: v20.5.0

지정된 문자 수의 고정 길이 무작위 문자열을 생성합니다.
반환되는 문자가 반드시 ASCII 문자일 필요는 없으므로, 출력할 수 없는 문자일 수도 있습니다.

**구문**

```sql theme={null}
randomFixedString(length)
```

**인수**

* `length` — 문자열의 길이(바이트 단위)입니다. [`UInt*`](/ko/reference/data-types/int-uint)

**반환 값**

임의의 바이트로 채워진 문자열을 반환합니다. [`FixedString`](/ko/reference/data-types/fixedstring)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randomFixedString(13) AS rnd, toTypeName(rnd)
```

```response title=Response theme={null}
┌─rnd──────┬─toTypeName(randomFixedString(13))─┐
│ j▒h㋖HɨZ'▒ │ FixedString(13)                 │
└──────────┴───────────────────────────────────┘
```

<div id="randomPrintableASCII">
  ## randomPrintableASCII
</div>

도입 버전: v20.1.0

지정한 길이의 임의 [ASCII](https://en.wikipedia.org/wiki/ASCII#Printable_characters) 문자열을 생성합니다.

`length < 0`을 전달하면 함수의 동작이 정의되지 않습니다.

**구문**

```sql theme={null}
randomPrintableASCII(length[, x])
```

**인수**

* `length` — 바이트 단위 문자열 길이입니다. [`(U)Int*`](/ko/reference/data-types/int-uint)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 동일한 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)이 적용되지 않도록 하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

무작위 ASCII 출력 가능 문자로 이루어진 문자열을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT number, randomPrintableASCII(30) AS str, length(str) FROM system.numbers LIMIT 3
```

```response title=Response theme={null}
┌─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 │
└────────┴────────────────────────────────┴──────────────────────────────────┘
```

<div id="randomString">
  ## randomString
</div>

도입 버전: v20.5.0

지정한 개수의 문자로 이루어진 임의의 문자열을 생성합니다.
반환되는 문자가 반드시 ASCII 문자는 아니므로, 출력할 수 없는 문자일 수 있습니다.

**구문**

```sql theme={null}
randomString(length[, x])
```

**인수**

* `length` — 문자열의 길이(바이트)입니다. [`(U)Int*`](/ko/reference/data-types/int-uint)
* `x` — 선택 사항이며 무시됩니다. 이 인수의 유일한 목적은 같은 함수 호출을 하나의 쿼리에서 여러 번 사용할 때 [공통 하위 표현식 제거](/ko/reference/functions/regular-functions/overview#common-subexpression-elimination)을 방지하는 것입니다. [`Any`](/ko/reference/data-types)

**반환 값**

무작위 바이트로 채워진 문자열을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randomString(5) AS str FROM numbers(2)
```

```response title=Response theme={null}
���
�v6B�
```

<div id="randomStringUTF8">
  ## randomStringUTF8
</div>

도입 버전: v20.5.0

지정된 개수의 코드 포인트로 이루어진 임의의 [UTF-8](https://en.wikipedia.org/wiki/UTF-8) 문자열을 생성합니다.
할당되지 않은 [평면](https://en.wikipedia.org/wiki/Plane_\(Unicode\))(4번부터 13번 평면까지)의 코드 포인트는 반환되지 않습니다.
다만 ClickHouse 서버와 상호작용하는 클라이언트에서 생성된 UTF-8 문자열을 올바르게 표시하지 못할 수도 있습니다.

**구문**

```sql theme={null}
randomStringUTF8(length)
```

**인수**

* `length` — 문자열의 길이(코드 포인트 수 기준). [`(U)Int*`](/ko/reference/data-types/int-uint)

**반환 값**

무작위 UTF-8 코드 포인트로 채워진 문자열을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT randomStringUTF8(13)
```

```response title=Response theme={null}
┌─randomStringUTF8(13)─┐
│ 𘤗𙉝д兠庇󡅴󱱎󦐪􂕌𔊹𓰛       │
└──────────────────────┘
```
