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字段的后面

以上基于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 );  -- 报错
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值