vi /root/data.txt
1,sss
2,dfdf
3,dfdf
4,changqun
data.txt中不要有空行,空行也是一条数据.
$ hive
创建一个表
hive>create table test(id int,name string) row format delimited fields terminated by ',';
加载数据
hive>LOAD DATA LOCAL INPATH '/root/data.txt' OVERWRITE INTO TABLE test;
查询即可看到结果
hive> select * from test;
OK
1 sss
2 dfdf
3 dfdf
4 changqun
Time taken: 2.701 seconds
1,sss
2,dfdf
3,dfdf
4,changqun
data.txt中不要有空行,空行也是一条数据.
$ hive
创建一个表
hive>create table test(id int,name string) row format delimited fields terminated by ',';
加载数据
hive>LOAD DATA LOCAL INPATH '/root/data.txt' OVERWRITE INTO TABLE test;
查询即可看到结果
hive> select * from test;
OK
1 sss
2 dfdf
3 dfdf
4 changqun
Time taken: 2.701 seconds
本文介绍如何使用Hive创建表并加载本地文件数据,通过具体实例演示了从创建表到加载数据及查询的全过程。
7080

被折叠的 条评论
为什么被折叠?



