Hadoop教程
HBase
Hive
Pig
Sqoop
Spark

Hive 动态分区

在动态分区中,表中存在分区列的值。因此,不需要手动传递分区列的值。
首先,选择我们要在其中创建表的数据库。
hive> use show;

动态分区 使用以下命令启用动态分区:-
hive> set hive.exec.dynamic.partition=true;  
hive> set hive.exec.dynamic.partition.mode=nonstrict;
创建一个虚拟表来存储数据。
hive> create table stud_demo(id int, name string, age int, institute string, course string) 
row format delimited
fields terminated by ',';

动态分区 现在,将数据加载到表中。
hive> load data local inpath '/home/codegyani/hive/student_details' into table stud_demo;

动态分区 使用以下命令创建分区表:-
hive> create table student_part (id int, name string, age int, institute string) 
partitioned by (course string)
row format delimited
fields terminated by ',';

动态分区 现在,将虚拟表的数据插入分区表。
hive> insert into student_part
partition(course)
select id, name, age, institute, course
from stud_demo;

动态分区
动态分区 在以下屏幕截图中,我们可以看到表student_part分为两类。 动态分区 让我们使用以下命令检索表的全部数据:-
hive> select * from student_part;

动态分区 现在,尝试使用以下命令检索基于分区列的数据:-
hive> select * from student_part where course= "java ";

动态分区
在这种情况下,我们不检查整个数据。因此,这种方法可以缩短查询响应时间。
我们还使用以下命令来检索另一个分区数据集的数据:-
hive> select * from student_part where course= "hadoop";

动态分区
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4