码迷,mamicode.com
首页 > 其他好文 > 详细

alter table

时间:2015-06-08 14:59:38      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

表重命名
  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;







alter table

标签:

原文地址:http://www.cnblogs.com/lishouguang/p/4560785.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!