创建一个log的表
create table log(user_id String,cid_sn String,mobile_data_ty String,os_ver String,mac
String,resolution String,commit_time String,sdk_ver String,device_id_type String,city String,androidid
String,device_model String,carrier String,promotion_channel String,app_ver_name String,imei
String,app_ver_code String,pid String,net_type String,device_id String,app_device_id
String,release_channel String,country String,time_zone String,os_name String,manufacture
String,commit_id String,app_token String,account String,app_id String,build_num String,language
String)partitioned by(time string,pai string)row format delimited fields terminated by ',';
linux数据本地上传hive表
load data local inpath '/opt/b.txt' into table data partition(time='20190118',pai ='ios');
hdfs数据上传hive表
load data inpath '/Android' into table data partition(time='20190118',pai ='ios');
hive清空表
insert overwrite table data select * from data where 1=0;
清空分区
ALTER TABLE data DROP PARTITION (time='20180118');
取出日活跃的最后一条记录(提前创建一个active_day表分区只有一个time)
insert into table active_day partition(time ='20180428')select user_id,cid_sn,mobile_data_ty,os_ver
,mac,resolution,commit_time,sdk_ver,device_id_type,city,androidid,device_model,carrier,promotion_channe
l,app_ver_name,imei,app_ver_code,pid,net_type,device_id,app_device_id,release_channel,country,time_zone
,os_name,manufacture,commit_id,app_token,account,app_id,build_num,language from(select * ,row_number()
over(partition by user_id order by commit_time)as rn from log where time ='20180428') as tmp where rn =
1;