第19天: stutct

来源:互联网 发布:多标签分类算法 编辑:程序博客网 时间:2024/05/17 06:23
Hive学习实战   
--------------------------------------------------------------
Hive从入门到实战【40讲】---笔记记录
--------------------------------------------------------------
 
hive命令
1、show tables;
2、show databases;
3、 desc login; ---查看表结构。
4、 show partitions test5; --查看分区




load data local inpath
'/hadoop/hive0.9/testHive/login_struct.txt'
into table login_struct;


第19天: stutct


 


create table login_struct(
 ip string,
 user struct<uid:bigint,name :string>
 )
 partitioned by (dt string)
 row format delimited
 fields terminated by ','
 collection items terminated by '|'
 stored as textfile;


printf "%s,%s|%s\n" 192.168.1.1 2000000 blue >> login_struct.txt
printf "%s,%s|%s\n" 192.168.1.2 2000001 red >> login_struct.txt




load data local inpath
'/hadoop/hive0.9/testHive/login_struct.txt'
overwrite into table login_struct partition (dt='20150207');




stuct可以根据 . 来查询。


select  ip,user.uid from login_struct;



















































0 0