Hive导出数据到MYSQL . 笔记

 1.

vim export.sql:

SELECT
IF(player_id is not NULL,player_id,'  '),
IF(regist_time is not NULL,regist_time,0),
IF(online_time_num is not NULL,online_time_num,0),
IF(last_login_time is not NULL,last_login_time,0),
IF(last_login_ip is not NULL,last_login_ip,'0.0.0.0'),
IF(`level` is not NULL,`level`,0),
IF(coin is not NULL,coin,0),
IF(game_id is not NULL,game_id,0),
IF(agent_id is not NULL,agent_id,0),
IF(server_id is not NULL,server_id,0),
IF(`date` is not NULL,`date`,'0000-00-00'),
IF(`name` is not NULL,`name`,'  ')
FROM fycenter.members
WHERE (
(`date`='2012-03-01' AND game_id=5 AND agent_id IN (135,127) )
OR (`date`='2012-02-29' AND game_id=6 AND agent_id IN (173,184) )
OR (`date`='2012-02-29' AND game_id=7 AND agent_id IN (329, 337,331) )
OR (`date`='2012-02-29' AND game_id=10 AND agent_id = 282)
OR (`date`='2012-02-29' AND game_id=12 AND agent_id IN (217,213) )
OR (`date`='2012-02-29' AND game_id=13 AND agent_id=370)
OR (`date`='2012-02-29' AND game_id=3)




2. 命令行下执行:
/opt/hive/bin/hive -f export.sql > export.result2.txt


cp export.result2.txt > /tmp/export.result2.txt


mysql -uroot -pxxx123 olap -hxxx.xxx.xxx.xxx

清空表
> truncate table members;
> Load data infile '/tmp/export.result2.txt' Into table members    (    ) ;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值