HiveSQL_添加数据load

互联网 2022/1/15 2:03:47

创建表 create table person( id int comment "唯一标识", name string comment "名称", likes array<string> comment "爱好", address map<string,string> comment "地址" ) row format delimited fields terminat…

创建表

create table person(
id int comment "唯一标识",
name string comment "名称",
likes array<string> comment "爱好",
address map<string,string> comment "地址"
)
row format delimited
fields terminated by ","
collection items terminated by "-"
map keys terminated by ":"
lines terminated by "\n";

准备person01.txt文件

[root@node4 data]# cat person01.txt 
1,小明 1,lol-book-movie,beijing:xisanqi-shanghai:pudong 
2,小明 2,lol-book-movie,beijing:xisanqi-shanghai:pudong 
3,小明 3,lol-book-movie,beijing:xisanqi-shanghai:pudong 
4,小明 4,lol-book-movie,beijing:xisanqi-shanghai:pudong 
5,小明 5,lol-movie,beijing:xisanqi-shanghai:pudong 
6,小明 6,lol-book-movie,beijing:xisanqi-shanghai:pudong 
7,小明 7,lol-book,beijing:xisanqi-shanghai:pudong 
8,小明 8,lol-book,beijing:xisanqi-shanghai:pudong 
9,小明 9,lol-book-movie,beijing:xisanqi-shanghai:pudong

load person01.txt文件加载数据

load data local inpath '/root/data/person01.txt' into table person;

查看person表数据

hive> select *from person;
OK
1	小明 1	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
2	小明 2	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
3	小明 3	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
4	小明 4	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
5	小明 5	["lol","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
6	小明 6	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong "}
7	小明 7	["lol","book"]	{"beijing":"xisanqi","shanghai":"pudong "}
8	小明 8	["lol","book"]	{"beijing":"xisanqi","shanghai":"pudong "}
9	小明 9	["lol","book","movie"]	{"beijing":"xisanqi","shanghai":"pudong"}
NULL	NULL	NULL	NULL
Time taken: 0.195 seconds, Fetched: 10 row(s)

随时随地学软件编程-关注百度小程序和微信小程序
关于找一找教程网

本站文章仅代表作者观点,不代表本站立场,所有文章非营利性免费分享。
本站提供了软件编程、网站开发技术、服务器运维、人工智能等等IT技术文章,希望广大程序员努力学习,让我们用科技改变世界。
[HiveSQL_添加数据load]http://www.zyiz.net/tech/detail-285308.html

赞(0)
关注微信小程序
程序员编程王-随时随地学编程

扫描二维码或查找【程序员编程王】

可以随时随地学编程啦!

技术文章导航 更多>
扫一扫关注最新编程教程