Updated on 2024-07-04 GMT+08:00

Restoring Multiversion Backup Data

Function

After the multiversion function is enabled, you can run the RESTORE TABLE statement to restore a table or partition of a specified version. For details about the syntax for enabling or disabling the multiversion function, see Enabling or Disabling Multiversion Backup.

Currently, the multiversion function supports only OBS tables created using the Hive syntax. For details about the syntax for creating a table, see Creating an OBS Table Using the Hive Syntax.

Syntax

  • Restore the non-partitioned table data to the backup data of a specified version.
    RESTORE TABLE [db_name.]table_name TO VERSION 'version_id';
  • Restore the data of a single partition in a partitioned table to the backup data of a specified version.
    RESTORE TABLE [db_name.]table_name PARTITION (column = value, ...) TO VERSION 'version_id';

Keywords

  • RESTORE TABLE: Used to restore backup data
  • PARTITION: Used to specify the partition column
  • TO VERSION: Used to specify the version number You can run the SHOW HISTORY command to obtain the version number. For details, see Checking Multiversion Backup Data.

Parameters

Table 1 Parameters

Parameter

Description

db_name

Database name, which consists of letters, digits, and underscores (_). The value cannot contain only digits or start with a digit or underscore (_).

table_name

Table name

column

Partition column name

value

Value corresponding to the partition column name

version_id

Target version of the backup data to be restored You can run the SHOW HISTORY command to obtain the version number. For details, see Checking Multiversion Backup Data.

Precautions

Currently, the multiversion function supports only OBS tables created using the Hive syntax. For details about the syntax for creating a table, see Creating an OBS Table Using the Hive Syntax.

Example

  • Restore the data in non-partitioned table test_table to version 20210930.
    1
    RESTORE TABLE test_table TO VERSION '20210930';
    
  • Restore the data of partition dt in partitioned table test_table to version 20210930.
    1
    RESTORE TABLE test_table PARTITION (dt='2021-07-27') TO VERSION '20210930';