Hive 的查詢結果直接導入到 MySQL 中的方法


 

步驟一:

hive> add jar /setup/hive/lib/mysql-connector-java-5.1.25-bin.jar; hive> add jar /usr/lib/hive/lib/hive-contrib-0.9.0-cdh4.1.2.jar;

步驟二:

hive> CREATE TEMPORARY FUNCTION dboutput AS 'org.apache.Hadoop.hive.contrib.genericudf.example.GenericUDFDBOutput';

 


步驟三:

hive> select dboutput('jdbc:mysql://localhost/result','root','123456','INSERT INTO dc(code,size) VALUES (?,?)',code,size) from accesslog limit 10;

 


參考資料:

1、hive表直接入庫本地mysql,用udf從將hive的查詢結果直接寫入mysql數據庫中 
http://blog.sina.com.cn/s/blog_13088c10a0102wxit.html

2、hive將查詢結果,直接導入到mysql 
http://jxauwxj.iteye.com/blog/1947616


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM