1.创建分区
A、单分区建表语句:
hive> create table day_table(id int,
> content string)
> partitioned by (dt string)
> row format delimited foelds terminated by ',';
【单分区表,按天分区,在表结构中存在id,content,dt三列;以dt为文件夹区分】
B、双分区建表语句:
hive> create table day_hour_table(id int,
> content string)
> partitioned by (dt string,hour string)
> row format delimited foelds terminated by ',';
【双分区表,按天和小时分区,在表结构中新增加了dt和hour两列;先以dt为文件夹,再以hour子文件夹区分】
注意:在创建 删除多分区等操作时一定要注意分区的先后顺序,他们是父子节点的关系。分区字段不要和表字段相同。
2.添加表里面的分区
hive> alter table day_hour_table add partition (dt='2008-02-08', hour='07');

本文详细介绍了Hive的分区操作,包括创建单、双分区表,删除分区,数据加载,查看分区,重命名分区以及动态分区的操作,并强调了分区顺序、分区字段的选择以及内外部表的区别。同时,提供了动态分区的参数配置和实际操作命令。
最低0.47元/天 解锁文章
2607

被折叠的 条评论
为什么被折叠?



