Hive详细表结构操作(增加列,删除列,修改列,移动列)
1、向Hive表中添加某个字段
格式:alter table 表名 add columns (字段名 字段类型 comment '字段描述');
例1:alter table table_name add columns (now_time string comment '当前时间');
例2:alter table table_name add columns (now_time varchar(300) comment '当前时间');
2、在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字段的后面