Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

insert_* 세션 설정

이 설정은 system.settings에서 확인할 수 있으며, 소스 코드에서 자동 생성됩니다.

insert_allow_materialized_columns

유형
Bool
기본값
0

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

insert_deduplicate

유형
Bool
기본값
1

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

이 설정은 deduplicate_insertbackward_compatible_choice로 설정된 경우에만 적용됩니다.

가능한 값:

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

기본적으로 INSERT 문으로 복제된 테이블에 삽입된 블록은 중복 제거됩니다(Data Replication 참조). 복제된 테이블에서는 기본적으로 각 파티션에서 가장 최근의 100개 블록에 대해서만 중복 제거가 수행됩니다(replicated_deduplication_window, replicated_deduplication_window_seconds 참조). 복제되지 않은 테이블은 non_replicated_deduplication_window를 참조하십시오.

insert_deduplication_token

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

가능한 값:

  • 임의의 문자열

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

복제된 테이블의 경우 기본적으로 각 파티션에서 가장 최근의 삽입 100개만 중복 제거됩니다(replicated_deduplication_window, replicated_deduplication_window_seconds 참조). 복제되지 않은 테이블은 non_replicated_deduplication_window를 참조하십시오.

예시:

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

insert_null_as_default

유형
Bool
기본값
1

기본값 삽입을 활성화하거나 비활성화합니다. nullable 데이터 타입이 아닌 컬럼에 NULL 대신 기본값을 삽입합니다. 컬럼 타입이 널 허용이 아닌 상태에서 이 설정이 비활성화되어 있으면 NULL 삽입 시 예외가 발생합니다. 컬럼 타입이 널 허용인 경우에는 이 설정과 관계없이 NULL 값이 그대로 삽입됩니다.

이 설정은 INSERT … SELECT 쿼리에 적용됩니다. SELECT 서브쿼리는 UNION ALL 절로 연결할 수 있습니다.

가능한 값:

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

insert_shard_id

유형
UInt64
기본값
0

0이 아니면 데이터가 동기적으로 삽입될 분산 테이블의 세그먼트를 지정합니다.

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

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

SELECT uniq(shard_num) FROM system.clusters WHERE cluster = 'requested_cluster';

가능한 값:

  • 0 — 비활성화됩니다.
  • 해당 분산 테이블의 1부터 shards_num까지의 임의의 숫자.

예시

쿼리:

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;

결과:

┌─number─┐
│      0 │
│      0 │
│      1 │
│      1 │
│      2 │
│      2 │
│      3 │
│      3 │
│      4 │
│      4 │
└────────┘
Navigation