> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# insert_* 세션 설정

> insert_* 생성 그룹에 속한 ClickHouse 세션 설정입니다.

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>유형</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>기본값</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          재시작 없이 변경 가능
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

이 설정은 [system.settings](/docs/ko/reference/system-tables/settings)에서 확인할 수 있으며, [소스 코드](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp)에서 자동 생성됩니다.

<div id="insert_allow_materialized_columns">
  ## insert\_allow\_materialized\_columns
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

이 설정을 활성화하면 INSERT에서 materialized 컬럼을 허용합니다.

<div id="insert_deduplicate">
  ## insert\_deduplicate
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

`INSERT`의 블록 중복 제거를 활성화하거나 비활성화합니다(복제된 테이블(Replicated\* tables)용).

가능한 값:

* 0 — 비활성화됨.
* 1 — 활성화됨.

기본적으로 `INSERT` 문으로 복제된 테이블에 삽입된 블록은 중복 제거됩니다([Data Replication](/docs/ko/reference/engines/table-engines/mergetree-family/replication) 참조).
복제된 테이블에서는 기본적으로 각 파티션에서 가장 최근의 100개 블록에 대해서만 중복 제거가 수행됩니다([replicated\_deduplication\_window](/docs/ko/reference/settings/merge-tree-settings#replicated_deduplication_window), [replicated\_deduplication\_window\_seconds](/docs/ko/reference/settings/merge-tree-settings#replicated_deduplication_window_seconds) 참조).
복제되지 않은 테이블은 [non\_replicated\_deduplication\_window](/docs/ko/reference/settings/merge-tree-settings#non_replicated_deduplication_window)를 참조하십시오.

<div id="insert_deduplication_token">
  ## insert\_deduplication\_token
</div>

이 설정을 사용하면 사용자가 MergeTree/ReplicatedMergeTree에서 자체 중복 제거 방식을 지정할 수 있습니다.
예를 들어 각 INSERT 문에서 이 설정에 고유한 값을 지정하면,
동일한 데이터가 삽입되더라도 중복 제거되지 않도록 할 수 있습니다.

가능한 값:

* 임의의 문자열

`insert_deduplication_token`은 비어 있지 않은 경우에만 중복 제거에 사용됩니다.

복제된 테이블의 경우 기본적으로 각 파티션에서 가장 최근의 삽입 100개만 중복 제거됩니다([replicated\_deduplication\_window](/docs/ko/reference/settings/merge-tree-settings#replicated_deduplication_window), [replicated\_deduplication\_window\_seconds](/docs/ko/reference/settings/merge-tree-settings#replicated_deduplication_window_seconds) 참조).
복제되지 않은 테이블은 [non\_replicated\_deduplication\_window](/docs/ko/reference/settings/merge-tree-settings#non_replicated_deduplication_window)를 참조하십시오.

<Note>
  `insert_deduplication_token`은 파티션별로 추적되므로, 하나의 삽입으로 기록된 여러 파티션에 동일한 토큰을 사용할 수 있습니다. 토큰이 없으면 기본 콘텐츠 체크섬이 삽입된 전체 블록을 기준으로 계산되므로, 삽입은 전체 데이터가 이전 삽입(재시도)과 완전히 일치할 때에만 중복 제거되며, 단일 파티션의 행이 우연히 다른 삽입과 일치하는 경우에는 중복 제거되지 않습니다.
</Note>

예시:

```sql theme={null}
CREATE TABLE test_table
( A Int64 )
ENGINE = MergeTree
ORDER BY A
SETTINGS non_replicated_deduplication_window = 100;

INSERT INTO test_table SETTINGS insert_deduplication_token = 'test' VALUES (1);

-- the next insert won't be deduplicated because insert_deduplication_token is different
INSERT INTO test_table SETTINGS insert_deduplication_token = 'test1' VALUES (1);

-- the next insert will be deduplicated because insert_deduplication_token
-- is the same as one of the previous
INSERT INTO test_table SETTINGS insert_deduplication_token = 'test' VALUES (2);

SELECT * FROM test_table

┌─A─┐
│ 1 │
└───┘
┌─A─┐
│ 1 │
└───┘
```

<div id="insert_null_as_default">
  ## insert\_null\_as\_default
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

[기본값](/docs/ko/reference/statements/create/table#default_values) 삽입을 활성화하거나 비활성화합니다. [nullable](/docs/ko/reference/data-types/nullable) 데이터 타입이 아닌 컬럼에 [NULL](/docs/ko/reference/syntax#null) 대신 기본값을 삽입합니다.
컬럼 타입이 널 허용이 아닌 상태에서 이 설정이 비활성화되어 있으면 `NULL` 삽입 시 예외가 발생합니다. 컬럼 타입이 널 허용인 경우에는 이 설정과 관계없이 `NULL` 값이 그대로 삽입됩니다.

이 설정은 [INSERT ... SELECT](/docs/ko/reference/statements/insert-into#inserting-the-results-of-select) 쿼리에 적용됩니다. `SELECT` 서브쿼리는 `UNION ALL` 절로 연결할 수 있습니다.

가능한 값:

* 0 — 널 허용이 아닌 컬럼에 `NULL`을 삽입하면 예외가 발생합니다.
* 1 — `NULL` 대신 컬럼의 기본값이 삽입됩니다.

<div id="insert_shard_id">
  ## insert\_shard\_id
</div>

<SettingsInfoBlock type="UInt64" default_value="0" />

`0`이 아니면 데이터가 동기적으로 삽입될 [분산](/docs/ko/reference/engines/table-engines/special/distributed) 테이블의 세그먼트를 지정합니다.

`insert_shard_id` 값이 올바르지 않으면 서버에서 예외를 발생시킵니다.

`requested_cluster`의 세그먼트 수를 확인하려면 서버 구성(config)을 확인하거나 다음 쿼리를 사용할 수 있습니다:

```sql theme={null}
SELECT uniq(shard_num) FROM system.clusters WHERE cluster = 'requested_cluster';
```

가능한 값:

* 0 — 비활성화됩니다.
* 해당 [분산](/docs/ko/reference/engines/table-engines/special/distributed) 테이블의 `1`부터 `shards_num`까지의 임의의 숫자.

**예시**

쿼리:

```sql theme={null}
CREATE TABLE x AS system.numbers ENGINE = MergeTree ORDER BY number;
CREATE TABLE x_dist AS x ENGINE = Distributed('test_cluster_two_shards_localhost', currentDatabase(), x);
INSERT INTO x_dist SELECT * FROM numbers(5) SETTINGS insert_shard_id = 1;
SELECT * FROM x_dist ORDER BY number ASC;
```

결과:

```text theme={null}
┌─number─┐
│      0 │
│      0 │
│      1 │
│      1 │
│      2 │
│      2 │
│      3 │
│      3 │
│      4 │
│      4 │
└────────┘
```
