数据湖探索 DLI-创建表时指定表的生命周期:示例

时间:2024-07-01 21:07:17

示例

  • DataSource语法新建test_datasource_lifecycle表,生命周期为100天
    1
    2
    3
    CREATE TABLE test_datasource_lifecycle(id int) 
    USING parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=100);
    
  • Hive语法新建test_hive_lifecycle表,生命周期为100天。
    1
    2
    3
    CREATE TABLE test_hive_lifecycle(id int) 
    stored as parquet 
    TBLPROPERTIES( "dli.lifecycle.days"=100);
    
  • DataSource语法新建test_datasource_lifecycle_obs表,生命周期为100天,过期时默认删除数据且数据备份至目录'obs://dli-test/'
    1
    2
    3
    4
    CREATE TABLE test_datasource_lifecycle_obs(name string, id int) 
    USING parquet 
    OPTIONS (path "obs://dli-test/xxx")
    TBLPROPERTIES( "dli.lifecycle.days"=100, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
    
  • Hive语法新建test_hive_lifecycle_obs表,生命周期为100天,过期时默认删除数据且数据备份至目录'obs://dli-test/'
    1
    2
    3
    4
    CREATE TABLE test_hive_lifecycle_obs(name string, id int) 
    STORED AS parquet 
    LOCATION 'obs://dli-test/xxx'
    TBLPROPERTIES( "dli.lifecycle.days"=100, "external.table.purge"='true', "dli.lifecycle.trash.dir"='obs://dli-test/Lifecycle-Trash' );
    
support.huaweicloud.com/sqlreference-dli/dli_08_0466.html