alter table
表重命名
alter table t1 rename to t2;
添加分区
alter table t1 add if not exists partition(xx=yy) location '/xx';
添加多个分区
alter table t1 add if not exists
partition(x1=y1) location '/x1'
partition(x2=y2) location '/x2'
partition(x3=y3) location '/x3';
修改分区
alter table t1 partition(xx=yy) set location '/xx';
删除分区
alter table t1 drop if exists partitioin(xx=yy);
添加列
alter table t1 add columns(id int, name string);
修改列
alter table t1 change column id id2 int comment '';
删除或者替换列
alter table t1 replace columns(id int comment '', name string comment'');
修改表属性
alter table t1 set tblproperties('k1'='v1');
修改表存储属性
alter table t1 set fileformat sequencefile;
alter table t1 partition(x=y) set fileformat sequencefile;
alter table t1 set serde 'xx.serde1' with serdeproperties('k1'='v1');
alter table t1 set serdeproperties('k1'='v1');
alter table t1 clustered by (id, name) sorted by (name) into 48 buckets;
归档分区
alter table t1 archive partition(year=2014);
alter table t1 unarchive partition(year=2014);
设置表是否可被删除
alter table t1 enable no_drop;
alter table t1 disable no_drop;
alter table t1 partition(x=y) enable no_drop;
设置表是否可被查询
alter table t1 enable offline;
alter table t1 disable offline;