Hive-查询结果导入到 MySQL
step1:
add jar /home/chenweidong/lib/hive-contrib-2.1.1-cdh6.0.0.jar;
add jar /home/chenweidong/lib/mysql-connector-java.jar;
step2:
CREATE TEMPORARY FUNCTION dboutput AS 'org.apache.hadoop.hive.contrib.genericudf.example.GenericUDFDBOutput';
step3:
SELECT dboutput('jdbc:mysql://localhost:3306/db_instance','user','password','INSERT INTO tb_name(shop_id,open_id) VALUES (?,?)',shop_sub_id,openid) FROM tm1 limit 10;
说明:
1)要确定CDH版本
2)tb_name 在 mysql中存在