Hive匯出資料到MYSQL 筆記

2021-06-05 08:28:24 字數 1448 閱讀 7323

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 -p***123 olap -h***.***.***.***

清空表》 truncate table members;

> load data infile '/tmp/export.result2.txt' into table members    (    ) ;

sqoop匯出hive表資料到mysql

直接在mysql裡從本地檔案系統匯入資料 mysql load data local infile c users asys documents tencent files 13174605 filerecv 2015082818 into table track log fields termin...

MYSQL匯出資料到Excel

select from tableinto outfile 路徑 嘗試使用 into outfile匯出資料的時候出現錯誤 the mysql server is running with the secure file priv option so it cannot execute this s...

hive資料匯出

一.操作前資料準備及資料資訊準備。二.使用select語句查詢結果寫入檔案中。命令範例一 命令範例二 註解 local的有無決定輸出檔案在本地檔案系統還是hdfs rowformat delimited fields terminated by t 決定檔案中資料的格式,且hive版本0.11之後才...