HiveSQL_添加数据load
作者:互联网
创建表
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)
标签:load,beijing,小明,HiveSQL,shanghai,pudong,lol,添加,xisanqi 来源: https://blog.csdn.net/manba_yqq/article/details/122504513