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