RESTORE

Platí pro:zaškrtnuté ano Databricks SQL zaškrtnuté ano Databricks Runtime

Obnoví tabulku Delta do dřívějšího stavu. Obnovení na dřívější číslo verze nebo časové razítko je podporováno.

Tato stránka obsahuje podrobnosti o použití správné syntaxe s příkazem RESTORE . Další pokyny k navigaci ve verzích tabulek Delta Lake pomocí tohoto příkazu najdete v části Práce s historií tabulek .

Syntaxe

RESTORE [ TABLE ] table_name [ TO ] time_travel_version

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

Parametry

  • timestamp_expression může být libovolná z těchto možností:
    • '2018-10-18T22:15:12.013Z'to znamená řetězec, který lze převést na časové razítko.
    • cast('2018-10-18 13:36:32 CEST' as timestamp)
    • '2018-10-18', to znamená řetězec data.
    • current_timestamp() - interval 12 hours
    • date_sub(current_date(), 1)
    • Jakýkoliv jiný výraz, který je nebo lze převést na časové razítko
  • version je dlouhá hodnota, kterou lze získat z výstupu DESCRIBE HISTORY table_spec.

timestamp_expression Ani version nemůže být poddotaz.

Příklady

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