1、修改表名
--格式:alter table 旧表名 rename to 新表名;
--修改表名
alter table tb_data_tmp rename to tb_test;
2、为表添加注释
-- 修改表注释
alter table tb_test set tblproperties('comment' = '测试表');
-- 查看表信息
desc formatted tb_test;
3、向Hive表中添加字段
-- 添加单个字段
alter table tb_test add columns (gender string comment '性别');
-- 添加多个字段
alter table tb_test add columns
(
a string comment 'a列',
b string comment 'b列',
c string comment 'c列'
);
4、在Hive表中指定位置添加字段
注:分两步,先添加字段到最后(add columns),然后再移动到指定位置(change)
-- 添加在最后
alter table table_name add columns (c_time string comment '当前时间');
-- 移动到指定位置,address字段的后面
alter table table_name change c_time c_time string after address ;