日常数据文件自动入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

转载于:https://my.oschina.net/u/1866459/blog/645169

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值