微信搜索lxw1234bigdata | 邀请体验:数阅–数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

Hive中修改表的字段顺序

Hive lxw1234@qq.com 25349℃ 1评论

Hive中可以修改表的字段顺序。

如果发现Hive中创建的表字段顺序有问题,那么可以使用ALTER TABLE命令来修改,语法为:

ALTER TABLE table_name CHANGE col_old_name col_new_name column_type AFTER column_name;

具体例子如下:

 

hive> create table lxw1234_com (
    > a string,
    > b string,
    > c string
    > );
OK
Time taken: 0.107 seconds
hive> desc lxw1234_com;
OK
a                       string                                      
b                       string                                      
c                       string                                      
Time taken: 0.167 seconds, Fetched: 3 row(s)
hive> alter table lxw1234_com change column c c string after a;
OK
Time taken: 0.242 seconds
hive> desc lxw1234_com;
OK
a                       string                                      
c                       string                                      
b                       string                                      
Time taken: 0.14 seconds, Fetched: 3 row(s)
hive> 

如果觉得本博客对您有帮助,请 赞助作者

转载请注明:lxw的大数据田地 » Hive中修改表的字段顺序

喜欢 (21)
分享 (0)
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(1)个小伙伴在吐槽
  1. 感谢,很管用
    Northern2019-03-01 14:44 回复