当前位置:   article > 正文

Hive 在指定位置添加字段_hive 已有表可以在固定位置插入字段吗

hive 已有表可以在固定位置插入字段吗

本文转载至:https://blog.csdn.net/u010002184/article/details/90143932

此处仅为mark,方便查看。

捣腾了半天,终于找到解决方案了,hive定时任务原表添加字段的方法

分两步,先添加字段到最后(add columns),然后再移动到指定位置(change)

alter table table_name add columns (c_time string comment '当前时间'); -- 正确,添加在最后
alter table table_name change c_time c_time string after address ;  -- 正确,移动到指定位置,address字段的后面
  • 1
  • 2

以上基于Hive 2.0.0-SNAPSHOT,本人亲自实验的结论!!

如果添加字段时不加()会报错,网上有很多都没有(),如果写成“column”不加“s”也会报错!

alter table table_name add column c_time string comment '当前时间' after address ; -- 报错
alter table table_name add columns c_time string comment '当前时间' after address ;  -- 报错
alter table table_name add columns (c_time string comment '当前时间' after address );  -- 报错
  • 1
  • 2
  • 3
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/981273
推荐阅读
相关标签
  

闽ICP备14008679号