RESTORE

적용 대상:검사 '예'로 표시 Databricks SQL 검사 '예'로 표시 Databricks 런타임

Delta 테이블을 이전 상태로 복원합니다. 이전 버전 번호 또는 타임스탬프로의 복원이 지원됩니다.

이 페이지에는 명령과 함께 올바른 구문을 사용하는 방법에 대한 세부 정보가 포함되어 있습니다 RESTORE . 이 명령을 사용하여 Delta Lake 테이블 버전을 탐색하는 방법에 대한 자세한 지침은 Delta Lake 테이블 기록 작업을 참조하세요.

구문

RESTORE [ TABLE ] table_name [ TO ] time_travel_version

time_travel_version
 { TIMESTAMP AS OF timestamp_expression |
   VERSION AS OF version }

매개 변수

  • table_name

    복원할 델타 테이블을 식별합니다. 테이블 이름은 임시 사양을 사용하면 안됩니다.

  • timestamp_expression은 다음 중 하나일 수 있습니다.

    • '2018-10-18T22:15:12.013Z', 즉, 타임스탬프로 캐스팅할 수 있는 문자열
    • cast('2018-10-18 13:36:32 CEST' as timestamp)
    • '2018-10-18', 즉, 날짜 문자열
    • current_timestamp() - interval 12 hours
    • date_sub(current_date(), 1)
    • 타임스탬프이거나 타임스탬프로 캐스팅될 수 있는 기타 식
  • versionDESCRIBE HISTORY table_spec 출력에서 가져올 수 있는 긴 값입니다.

timestamp_expressionversion는 모두 하위 쿼리가 될 수 없습니다.

예제

-- Restore the employee table to a specific timestamp
> RESTORE TABLE employee TO TIMESTAMP AS OF '2022-08-02 00:00:00';
 table_size_after_restore num_of_files_after_restore num_removed_files num_restored_files removed_files_size restored_files_size
                      100                          3                 1                  0                574                   0

-- Restore the employee table to a specific version number retrieved from DESCRIBE HISTORY employee
> RESTORE TABLE employee TO VERSION AS OF 1;
 table_size_after_restore num_of_files_after_restore num_removed_files num_restored_files removed_files_size restored_files_size
                      100                          3                 1                  0                574                   0

-- Restore the employee table to the state it was in an hour ago
> RESTORE TABLE employee TO TIMESTAMP AS OF current_timestamp() - INTERVAL '1' HOUR;
 table_size_after_restore num_of_files_after_restore num_removed_files num_restored_files removed_files_size restored_files_size
                      100                          3                 1                  0                574                   0