sqoop merge

来源:互联网 发布:剑三藏剑捏脸数据成男 编辑:程序博客网 时间:2024/06/05 00:13

1)生成jar包:

sqoop codegen --connect jdbc:oracle:thin:@ip:1521:orcl --username TJAMIS_LXF --password *****--table T03_POLICYPERDAY_TEST

2)导入数据:

sqoop import --connect jdbc:oracle:thin:@ip:orcl --username tjamis_lxf --password ******--table T03_POLICYPERDAY_TEST --verbose -m 1   --hive-import --hive-table TJAMIS_LXF.T03_POLICYPERDAY_TEST --split-by T00STATDATE  --hive-overwrite -z --create-hive-table --hive-drop-import-delims --fields-terminated-by ","
sqoop import --connect jdbc:oracle:thin:@ip:orcl --username tjamis_lxf --password ******--table T03_POLICYPERDAY_TEST_NEW --verbose -m 1   --hive-import --hive-table TJAMIS_LXF.T03_POLICYPERDAY_TEST_NEW --split-by T00STATDATE  --hive-overwrite -z --create-hive-table --hive-drop-import-delims --fields-terminated-by ","

注意:导入数据需要加上: --fields-terminated-by ","

否则报错:



3)sqoop merge --new-data /user/hive/warehouse/tjamis_lxf.db/t03_policyperday_test_new --onto /user/hive/warehouse/tjamis_lxf.db/t03_policyperday_test --target-dir /user/root/t03_policyperday_merge --jar-file T03_POLICYPERDAY_TEST.jar --class-name T03_POLICYPERDAY_TEST --merge-key PID 

说明:T03_POLICYPERDAY_TEST.jar是第一步1)生成的jar文件

--target-dir 是merge后产生的结果目录!!!

--new-data 和--onto 分别是第二步2)导入的增量数据和全量数据!!!

--merge-key 是合并主键!




0 0
原创粉丝点击