HIVE---TBLPROPERTIES

本文详细介绍了Hive中TBLPROPERTIES的使用,包括EXTERNAL、auto.purge、immutable和orc.compress等内置属性的作用及如何通过ALTERTABLE命令修改这些属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

介绍

    TBLPROPERTIES是表的一些属性,HIVE内置了一部分属性,使用者也可以在创建表时进行自定义;

HIVE内置的TBLPROPERTIES

在这里插入图片描述

  • EXTERNAL: 通过修改此属性可以实现内部表和外部表的转化,如下:
    alter table table_name set TBLPROPERTIES ('EXTERNAL'='TRUE'); //内部表转外部表 alter table table_name set TBLPROPERTIES ('EXTERNAL'='FALSE'); //外部表转内部表
  • auto.purge: 当设置为ture时,删除或者覆盖的数据会不经过回收站,直接被删除。配置了此属性会影响到这些操作: Drop Table, Drop Partitions, Truncate Table,Insert Overwrite;
  • immutable: 当表的这个属性为true时,若表中无数据时可以insert数据,但是当表已经有数据时,insert操作会失败。不可变表用来防止意外更新,避免因脚本错误导致的多次更新,而没有报错。
  • orc.compress: 用来指定orc存储的压缩方式;

修改TBLPROPERTIES

ALTER TABLE table_name SET TBLPROPERTIES (property_name = property_value, property_name = property_value, ... );

参考:

  1. 官网说明:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTableCreate/Drop/TruncateTable
  2. https://blog.youkuaiyun.com/mhtian2015/article/details/78776112
### Hive TBLPROPERTIES Usage and Examples In managing data within a data warehouse environment, properties associated with tables play an essential role in optimizing performance and maintaining metadata integrity. In Hive, `TBLPROPERTIES` allows users to add custom key-value pairs that provide additional information about the table. The syntax for setting these properties during table creation or modification involves specifying one or more property names along with their corresponding values: ```sql CREATE TABLE example_table ( id INT, name STRING ) TBLPROPERTIES ('property_key'='value'); ``` For existing tables, updating properties requires altering the table definition: ```sql ALTER TABLE example_table SET TBLPROPERTIES ('new_property'='another_value'); ``` These properties serve various purposes including but not limited to defining external parameters like serialization formats, partitioning strategies, bucket count, etc., which are crucial when integrating complex datasets into environments such as those managed by SQL Server Analysis Services[^1]. Commonly utilized keys include: - **serialization.format**: Specifies how columns should be serialized/deserialized. - **EXTERNAL**: Indicates whether the table points to files outside of Hive's control. - **transient_lastDdlTime**: Records timestamp indicating last DDL operation time automatically maintained by Hive. When dealing with large-scale operations involving multiple systems, ensuring proper configuration via `TBLPROPERTIES` becomes even more important especially considering aspects related to data pipelines where ETL processes move data between different storage solutions[^2]. For instance, configuring appropriate settings helps ensure efficient handling of big data scenarios requiring distributed processing frameworks like Hadoop DFS or stream processing platforms like Apache Kafka[^3].
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值