首页 > 其他 > 详细

Hive的表属性操作

时间:2015-07-18 18:34:11      阅读:7024      评论:0      收藏:0      [点我收藏+]

修改表名

alter table table_name rename to new_table_name

技术分享

增加列

alter table tablename add columns(c1 string comment ‘xxxx‘,
c2 long comment ‘yyyy‘)

技术分享

修改列名

alter table tablename change column c_Old c_New int comment ‘XXXXXX‘

after severity;//可以把该列放到指定列的后而,或者使用’first’放到第一位。

技术分享

修改表属性tblproperties

alter table tablename set tblproperties(
property_name=property_value,property_name=property_value,…
);

技术分享

修改表属性serdeproperties

注意:针对无分区表与有分区表不同。

无分区

alter table tablename set serdeproperties(
‘field.delim‘=‘\t‘
);

技术分享

技术分享

有分区

alter table tablename partition(dt=‘xxxx‘) set serdeproperties
(‘field.delim‘=‘\t‘);

技术分享

技术分享

修改location

布置只有外部表可以指定location,内部表也可以指定location。
alter table table_name [partition(...)] set location ‘path‘

技术分享

技术分享

技术分享

验证:
select * from city;
删除表同样也会将指定位置的文件目录删除。

内部表转外部表

alter table tablename set TBLPROPERTIES (‘EXTERNAL‘ = ‘TRUE‘);

外部表转内部表

alter table table_name set TBLPROPERTIES(‘EXTERNAL‘=‘FALSE‘);

技术分享

技术分享

技术分享

版权声明:本文为博主原创文章,未经博主允许不得转载。

Hive的表属性操作

原文:http://blog.csdn.net/scgaliguodong123_/article/details/46941419

(0)
(2)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!