Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1030384
  • 博文数量: 164
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1336
  • 用 户 组: 普通用户
  • 注册时间: 2016-03-11 14:13
个人简介

狂甩酷拽吊炸天

文章分类

全部博文(164)

文章存档

2023年(1)

2022年(3)

2021年(4)

2020年(17)

2019年(37)

2018年(17)

2017年(35)

2016年(50)

分类: LINUX

2019-12-02 17:34:07

最近经常遇到hive的表要在某个表的指定位置添加字段,总结一下:

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

点击(此处)折叠或打开

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

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

点击(此处)折叠或打开

  1. alter table table_name add column c_time string comment '当前时间' after address ; -- 报错
  2. alter table table_name add columns c_time string comment '当前时间' after address ; -- 报错
  3. alter table table_name add columns (c_time string comment '当前时间' after address ); -- 报错
  4. alter table table_name add columns (c_time string comment '当前时间') after address ; -- 报错


阅读(28229) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~