文件入hive库中表

1.hive建表

create EXTERNAL table IF NOT EXISTS  exttable_map_mdn_city

(

sdate string,

mdn string,

province string,

city string,

times int

)

partitioned by (dt string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' location '/user/noc/private/exttable_map_mdn_city/';


hive -e "use noc_dpi;alter table exttable_map_mdn_city add partition (dt='$lastday') location '/user/noc/private/ext_tables/exttable_map_mdn_city/$lastday' "

2. hive中文只支持UTF-8编码

iconv   -f gbk -t utf-8<mpm_tot_$lastday.txt>mpm_tot_$lastday.dat

rm mpm_tot_$lastday.txt

mv mpm_tot_$lastday.dat mpm_tot_$lastday.txt

3.文件入库

hadoop fs -put mpm_tot_201601$i.txt /user/noc/private/ext_tables/exttable_map_mdn_city/$lastday

ls mpm_tot_$lastday.txt

hadoop fs -du /user/noc/private/ext_tables/exttable_map_mdn_city/20160131

你可能感兴趣的:(文件入hive库中表)