一、hive添加字段到指定位置
先添加字段到最后位置再移动到指定位置
1、添加字段
ADD COLUMNS允许用户在当前列的末尾,分区列之前添加新的列
alter table table_name add columns (age string comment '当前时间') cascade;
2、移动字段到指定位置
-- 移动在某个字段后面
alter table table_name change age age string comment '年龄' after id ;
-- 移动到开头位置
alter table table_name change age age string comment '年龄' first;
-- 修改字段类型
alter table table_name change column age age string;
-- 替换表字段(REPLACE COLUMNS允许用户更新列,更新的过程是先删除当前的列,然后在加入新的列)
注:只有在使用native的SerDE时才可以这么做。
alter table table_name replace columns (age int comment '年龄', uage int comment '你的名字') ;
3、修改表的属性
(1) 将table_n