美文网首页
hive操作数据

hive操作数据

作者: 人活一世 | 来源:发表于2017-09-26 17:30 被阅读0次

    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;

    相关文章

      网友评论

          本文标题:hive操作数据

          本文链接:https://www.haomeiwen.com/subject/gwoxextx.html