一、静态分区
1、创建一张分区表
create table test_part_table(word string,num bigint )partitioned by(dt
string)row format delimited fields terminated by ‘\t’;
可以看出,表中除了word string,num bigint两个字段外,还多了个dt字段。
2、插入数据
依次执行以下两条语句
insert overwrite table test_part_table partition (dt=‘001’) select ‘o’,1 ;
insert overwrite table test_part_table partition (dt=‘002’) select ‘k’,2 ;
表中数据如下:
- 注意:Insert overwrite table partition select xxx 会覆盖由select返回的数据集中现有的分区。
再次往002分区中插入数据
insert overwrite table test_part_table partition (dt=‘002’) select ‘h’,3 ;
Hive分区表操作详解

本文介绍了Hive静态分区表的使用,包括如何创建分区表、插入数据以及查看分区表在HDFS上的存储情况。通过示例展示了`insert overwrite table partition`语句如何覆盖现有分区数据。


最低0.47元/天 解锁文章
715

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



