UNDROP TABLE 문

UNDROP TABLE 문

UNDROP TABLE은 테이블 삭제(DROP)를 취소해요. ClickHouse 버전 23.3부터 DROP TABLE을 실행한 뒤 database_atomic_delay_before_drop_table_sec 설정으로 정해진 기간(기본 8분) 안에는 Atomic 데이터베이스의 테이블을 UNDROP TABLE로 복구할 수 있어요.

출처: 문서

본문

테이블 삭제를 취소해요. ClickHouse 버전 23.3부터 DROP TABLE을 실행한 뒤 database_atomic_delay_before_drop_table_sec(기본 8분)에 의해 설정된 기간 동안 Atomic 데이터베이스의 테이블을 UNDROP TABLE로 복구할 수 있어요. Atomic 데이터베이스에서 삭제된 테이블은 system.dropped_tables에 나열돼요. ClickHouse Cloud의 Shared 데이터베이스에서는 이 기간이 대신 database_shared_drop_table_delay_seconds로 제어되며, 기본값은 8시간이에요. Shared 데이터베이스에서 삭제된 테이블은 system.dropped_tables에 나열되지 않아요. 삭제된 테이블과 연결된 TO 절이 없는 materialized view가 있다면, 그 뷰의 내부 테이블도 UNDROP 해야 해요. DROP TABLE도 참고해요.

Syntax (구문):

UNDROP TABLE [db.]name [UUID '<uuid>'] [ON CLUSTER cluster]

Example (예제)

CREATE TABLE tab
(
    `id` UInt8
)
ENGINE = MergeTree
ORDER BY id;

DROP TABLE tab;

SELECT *
FROM system.dropped_tables
FORMAT Vertical;
Row 1:
──────
index:                 0
database:              default
table:                 tab
uuid:                  aa696a1a-1d70-4e60-a841-4c80827706cc
engine:                MergeTree
metadata_dropped_path: /var/lib/clickhouse/metadata_dropped/default.tab.aa696a1a-1d70-4e60-a841-4c80827706cc.sql
table_dropped_time:    2023-04-05 14:12:12

1 row in set. Elapsed: 0.001 sec.
UNDROP TABLE tab;

SELECT *
FROM system.dropped_tables
FORMAT Vertical;
Ok.

0 rows in set. Elapsed: 0.001 sec.
DESCRIBE TABLE tab
FORMAT Vertical;
Row 1:
──────
name:               id
type:               UInt8
default_type:
default_expression:
comment:
codec_expression:
ttl_expression:

Related (관련): DROP, DETACH, ATTACH

더 알아보기 (Learn more)