1.启动服务器到后台
nohup bin/hiveserver2 1>/dev/null 2>&1 &
2.连接
bin/beeline -u jdbc:hive2://hadoop01:10000 -n root
3.建表
create table t_order(id string,o_time string,amount int,price float)
row format delimited fields terminated by ‘,’;
4.将数据导入hive表
load data local inpath ‘/root/order.dat’ into table t_access;
5.array数组类型建表
create table t_order(id string,o_time string,amount int,price float,use array)
row format delimited fields terminated by ‘,’
collection items terminated by ‘;’;
6.map类型建表
create table t_order(id string,o_time string,amount int,price float,use_level map<string,string>)
row format delimited fields terminated by ‘,’
collection items terminated by ‘#’
map keys terminated by ‘:’;
通过key获取value
select name,family_members[‘father’] from t_person;
获取所有的key
select name,map_keys(family_members) from t_person;
获取所有的value
select name,map_values(family_members) from t_person;
7.struct类型
create table t_order(id string,o_time string,o_items struct<i_name:string,i_amount:int,i_price:float>)
row format delimited fields terminated by ‘,’
collection items terminated by ‘:’;
8.使用本地模式进行运算
set hive.exec.mode.local.auto=true;
hive常用命令
最新推荐文章于 2025-07-15 00:12:32 发布