Hive数据导入方式

本文介绍了如何使用Hive进行表的创建、数据加载以及不同方式的数据导入操作,包括从本地和HDFS导入数据、静态及动态分区插入等,并提供了具体的SQL示例。

一、创建Hive表

 create table test001
    (id int, name string)
    partitioned by(age int)           //分区
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY '\t'
    STORED AS TEXTFILE;





建成表结构如下:







二、从本地导数据到Hive表


load data local inpath '/user/test001.txt' into table test001 partition (age=20) ;


三、从HDFS导数据到Hive表


load data  inpath '/user/haha/test001.txt' into table test001 partition (age=20) ;



四、从别的表中查询出相应的数据并导入到Hive表中



1.静态分区插入
insert into table test001
    partition (age='20')
    select id, name
     from test002;


2.动态分区插入

insert into table test001
     partition (age)
     select id, name,age
     from test002;


3.多表插入

from test003
     insert into table test001
     partition(age)
     select id, name, age
     insert into table test002
     select id, name
     where age>20;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值