Hive分区表新增字段及修改表名,列名,列注释,表注释,增加列,调整列顺序,属性名等操作

2023-05-26,,

一、Hive分区表新增字段

参考博客:https://blog.csdn.net/yeweiouyang/article/details/44851459

二、Hive修改表名,列名,列注释,表注释,增加列,调整列顺序,属性名等操作

参考博客:https://blog.csdn.net/helloxiaozhe/article/details/80749094

三、Hive分区表动态添加字段

参考博客:https://www.cnblogs.com/congzhong/p/8494991.html

四、Hive分区表修改表结构的问题

参考博客:https://blog.csdn.net/hanhaixingchen/article/details/53744132

五、hive改表结构的两个坑

参考博客:https://yq.aliyun.com/articles/66055

六、Hive分区表新增字段+重刷历史方法(避免旧分区新增字段为NULL)

参考博客:https://blog.csdn.net/hjw199089/article/details/79056612


e.g service_log添加字段

正确的方式:

alter table logs.service_log add columns (release_channel string) cascade;
alter table logs.service_log_lzo add columns (release_channel string) cascade;

此种方式会:

1、更新Table元数据;

2、更新Table所有分区的元数据;

3、service_log能正常解析出新增字段;

ALTER TABLE ADD|REPLACE COLUMNS with CASCADE command changes the columns of a table's metadata, and cascades the same change to all the partition metadata.

ADD COLUMNS lets you add new columns to the end of the existing columns but before the partition columns.

错误的方式:

alter table logs.service_log add columns (release_channel string);
alter table logs.service_log_lzo add columns (release_channel string);

注意:此种方式只会更新Table的元数据信息,不能解析出新增字段。

RESTRICT is the default, limiting column changes only to table metadata.

Hive分区表新增字段及修改表名,列名,列注释,表注释,增加列,调整列顺序,属性名等操作的相关教程结束。

《Hive分区表新增字段及修改表名,列名,列注释,表注释,增加列,调整列顺序,属性名等操作.doc》

下载本文的Word格式文档,以方便收藏与打印。