alter table

表重命名
  1. alter table t1 rename to t2;

添加分区
  1. alter table t1 add if not exists partition(xx=yy) location '/xx';

添加多个分区
  1. alter table t1 add if not exists 
  2. partition(x1=y1) location '/x1'
  3. partition(x2=y2) location '/x2'
  4. partition(x3=y3) location '/x3';

修改分区
  1. alter table t1 partition(xx=yy) set location '/xx';

删除分区
  1. alter table t1 drop if exists partitioin(xx=yy);

添加列
  1. alter table t1 add columns(id int, name string);

修改列
  1. alter table t1 change column id id2 int comment '';

删除或者替换列
  1. alter table t1 replace columns(id int comment '', name string comment'');

修改表属性
  1. alter table t1 set tblproperties('k1'='v1');

修改表存储属性
  1. alter table t1 set fileformat sequencefile;
  2. alter table t1 partition(x=y) set fileformat sequencefile;
  3. alter table t1 set serde 'xx.serde1' with serdeproperties('k1'='v1');
  4. alter table t1 set serdeproperties('k1'='v1');
  5. alter table t1 clustered by (id, name) sorted by (name) into 48 buckets;

归档分区
  1. alter table t1 archive partition(year=2014);
  2. alter table t1 unarchive partition(year=2014);

设置表是否可被删除
  1. alter table t1 enable no_drop;
  2. alter table t1 disable no_drop;
  3. alter table t1 partition(x=y) enable no_drop;

设置表是否可被查询
  1. alter table t1 enable offline;
  2. alter table t1 disable offline;







posted @ 2015-06-08 14:12  lishouguang  阅读(729)  评论(0编辑  收藏  举报