Hadoop13-Hive常用

本文详细介绍了如何使用Hive SQL创建外部表和分区表,包括定义字段、指定存储格式和位置,并演示了如何从本地文件系统加载数据到分区表中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

创建表

CREATE EXTERNAL TABLE test.user_info(id INT,uid STRING,item_id STRING,behavior_type INT,item_category STRING,visit_date DATE,province STRING) 
COMMENT 'user information!' 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' 
STORED AS TEXTFILE LOCATION '/bigdatacase/dataset';

创建分区表

create table tb_partition(id string, name string)
PARTITIONED BY (month string)
row format delimited fields terminated by '\t';

载入本地数据,常做测试用

create table test.user_partition(id string, name string)
PARTITIONED BY (month string)
row format delimited fields terminated by '\t';

load data local inpath '/home/sheldonwong/data/partition' 
overwrite into table test.user_partition 
partition(month='201709');

load data local inpath '/home/sheldonwong/data/partition2' 
overwrite into table test.user_partition 
partition(month='201708');

 

参考:

hive表分区 https://www.cnblogs.com/one--way/p/7550795.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值