hive加载数据

本文详细介绍了如何在Hive中加载数据,包括创建表时指定数据位置、本地数据及HDFS数据的加载、分区表数据加载,以及加载过程中的注意事项,如分隔符、数据类型对应问题和字段顺序等。特别强调了外部分区表加载时必须添加分区才能查看数据。
摘要由CSDN通过智能技术生成

创建表时加载

create table newtable as select col1,col2 from oldtable;

创建表时指定数据位置

create table tablename() location ''


root@ubuntu:~# cat student1.txt 
xiaoming    10
xiaohong    12
xiaoli  13
xiaowang    11

root@ubuntu:~# hadoop fs -mkdir /user/hive/warehouse/data

root@ubuntu:~#  hadoop fs -put student1.txt /user/hive/warehouse/data/

hive> create table student2(name string,age int) row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile location '/user/hive/warehouse/data/';
OK
Time taken: 0.272 seconds
hive> select * from student2;
OK
xiaoming    10
xiaohong    12
xiaoli  13
xiaowang    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值