hive操作数据

create table user_info (user_id int, cid string, ckid string, username string)

row format delimited

fields terminated by ‘\t’

lines terminated by ‘\n’;
创建表
要导入的数据格式
100636 100890 c5c86f4cddc15eb7 yyyvybtvt
100612 100865 97cc70d411c18b6f gyvcycy
100078 100087 ecd6026a15ffddf5 qa000100

导入本地数据
load data local inpath ‘/keduox/tmp/data.txt’ into table tt1;

rownumber()使用
create table tt1 (name varchar(25), wealth int, year varchar(25))
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘,’;
select *,row_num over(distribute by name sory by year desc from tt1;
select *,row_number() over(partition by wealth) from tt1;
select rn_tb.name,rn_tb.wealth from (select *,row_number() over(partition by name order by year desc) as rn from tt1) rn_tb where rn_tb.rn < 2;

    原文作者:深色星空
    原文地址: https://www.jianshu.com/p/55374dfc49cf
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞