2021-04-08

该篇博客介绍了如何在 Hive 中创建数据表,下载并导入数据,以及进行静态和动态分区操作。具体步骤包括创建 customer 表格,下载数据文件,设置基于 name 列的静态分区,并对 name=‘Arthur’ 的数据进行静态分区插入。同时,还展示了如何进行动态分区插入及删除特定分区。这些内容对于理解 Hive 中的数据管理和查询优化至关重要。
摘要由CSDN通过智能技术生成

1.创建customer表格(IDname date)
2.下载数据
3.设置静态分区(a创建分区表,使用name列作为分区
b.对name=Arthur创建静态分区)
4.动态分区
create table if not exists Customer(id string,name string,date1 string)
row format delimited fields terminated by’,’
lines terminated by’\n’ stored as textfile;

load data local inpath’/tools/datafiles/customer.txt’into table Customer;

create table if not exists part_customer (id string,date1 string)
partitioned by (name string) row format delimited fields terminated by’,’
lines terminated by’\n’stored as textfile;

insert into table part_customer partition (name = ‘Arthur’) select id,date1 from customer
where name = ‘Arthur’;

create table if not exists dyna_part_customer (id string,name string,date1 string) partitioned by (name string) row format delimited fields terminated by’,’ lines terminated by’\n’stored as textfile;

insert into table dyna_part_customer partition (name) select id,name,date1 from customer;

alter table dyna_part_cuatomer drop partition (name = ‘Arthur’);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值