Udostępnij za pośrednictwem


PRZYWRÓCIĆ

Dotyczy: zaznacz pole wyboru oznaczone jako tak Databricks SQL zaznacz pole wyboru oznaczone jako tak Databricks Runtime

Przywraca tabelę delty do wcześniejszego stanu. Przywracanie do wcześniejszego numeru wersji lub sygnatury czasowej jest obsługiwane.

Ta strona zawiera szczegóły dotyczące używania poprawnej składni z poleceniem RESTORE . Zobacz Praca z historią tabel usługi Delta Lake, aby uzyskać więcej wskazówek dotyczących nawigowania po wersjach tabel usługi Delta Lake za pomocą tego polecenia.

Składnia

RESTORE [ TABLE ] table_name [ TO ] time_travel_version

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

Parametry

  • table_name

    Identyfikuje tabelę delty do przywrócenia. Nazwa tabeli nie może używać specyfikacji czasowej.

  • timestamp_expression może być jednym z:

    • '2018-10-18T22:15:12.013Z', czyli ciąg, który można rzutować na znacznik czasu
    • cast('2018-10-18 13:36:32 CEST' as timestamp)
    • '2018-10-18', czyli ciąg daty
    • current_timestamp() - interval 12 hours
    • date_sub(current_date(), 1)
    • Dowolne inne wyrażenie, które jest lub można rzutować na znacznik czasu
  • version to długa wartość, którą można uzyskać z danych wyjściowych elementu DESCRIBE HISTORY table_spec.

Ani nie timestamp_expression version może być podzapytaniem.

Przykłady

-- 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