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;