forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
12 KiB
12 KiB
Disabling or Restoring the Lifecycle of a Table
Function
This section describes how to disable or restore the lifecycle of a specified table or partition.
You can disable or restore the lifecycle of a table in either of the following scenarios:
- If the lifecycle function has been enabled for a table or partitioned table, the system allows you to disable or restore the lifecycle of the table by changing the value of dli.table.lifecycle.status.
- If the lifecycle function is not enabled for a table or partitioned table, the system will add the dli.table.lifecycle.status property to allow you to disable or restore the lifecycle function of the table.
Constraints and Limitations
- The table lifecycle function currently only supports creating tables and versioning tables using Hive and Datasource syntax.
- The unit of the lifecycle is in days. The value should be a positive integer.
- The lifecycle can be set only at the table level. The lifecycle specified for a partitioned table applies to all partitions of the table.
Syntax
- This syntax can be used to disable or restore the lifecycle of a table at the table level.
1
ALTER TABLE table_name SET TBLPROPERTIES("dli.table.lifecycle.status"={enable|disable});
- This syntax can be used to disable or restore the lifecycle of a specified table at the table or partition table level.
1
ALTER TABLE table_name [pt_spec] LIFECYCLE {enable|disable};
Keywords
TBLPROPERTIES: Table properties, which can be used to extend the lifecycle of a table.
Parameters
Parameter |
Mandatory |
Description |
---|---|---|
table_name |
Yes |
Name of the table whose lifecycle is to be disabled or restored |
pt_spec |
No |
Partition information of the table whose lifecycle is to be disabled or restored. The format is partition_col1=col1_value1, partition_col2=col2_value1.... For a table with multi-level partitions, all partition values must be specified. |
enable |
No |
Restores the lifecycle function of a table or a specified partition.
|
disable |
No |
Disables the lifecycle function of a table or a specified partition.
|
Example
- Example 1: Disable the lifecycle function of the test_lifecycle table.
1
alter table test_lifecycle SET TBLPROPERTIES("dli.table.lifecycle.status"='disable');
- Example 2: Disable the lifecycle function for the partition whose time is 20230520 in the test_lifecycle table.
1
alter table test_lifecycle partition (dt='20230520') LIFECYCLE 'disable';
Parent topic: Table Lifecycle Management