- 添加列 add columns
alter table table_name add columns (id int comment '主鍵ID' ) ;
默認在表所有字段之后,分區字段之前。
- 替換列 replace columns ,會替換所有列,慎用
alter table table_name replace columns (id int comment '主鍵ID' ) ;
- 修改字段名稱、類型、注釋 change
1. 修改字段注釋
alter table table_name change id id int comment '訂單號';
2. 修改列名, id 改成 tab_id
alter table table_name change id tab_id int comment '訂單號';
- 刪除表分區
alter table table_name drop if exists partition (statis_date='20151015');
- 刪除文件(如果是外部表)
Hive 模式: dfs -rm -r -f /user/kimbo/table_name/statis_date=${date_7} ;
命令行模式: hadoop fs -rm -r /user/kimbo/table_name/statis_date=${date_7} ;