http://blog.csdn.net/linlinv3/article/details/49589615
sqoop import --connect jdbc:mysql://u13:3306/hive --username hive --password hive --table test --hive-import --hive-overwrite --hive-table testt --fields-terminated-by '\t'
Sqoop-1.4.4工具import和export使用详解
http://shiyanjun.cn/archives/624.html
sqoop导入数据至hive
http://lookqlp.iteye.com/blog/1666449
使用query导入hive表
sqoop import --connect jdbc:postgresql://ip/db_name --username user_name --query "select ,* from retail_tb_order where \$CONDITIONS" --hive-import -m 5 --hive-table hive_table_name (--hive-partition-key partition_name --hive-partition-value partititon_value);
注意:$CONDITIONS条件必须有,query子句若用双引号,则$CONDITIONS需要使用\转义,若使用单引号,则不需要转义。
从mysql增量导入hive
一通过where条件
sqoop import --connect jdbc:mysql://120.132.117.159:33306/protruly_mall_test --username inputuser --password inputpass --table mall_brand \
--where "DATE_FORMAT(CreatedDtm, '%Y-%m-%d')='2016-12-22'" --hive-import --hive-partition-key inputperiod --hive-partition-value 2016-12-22 \
--hive-overwrite --hive-table aggregate_data.mall_brand --fields-terminated-by '\t'
二通过lastValue
sqoop import --connect jdbc:mysql://120.132.117.159:33306/protruly_mall_test --username inputuser --password inputpass --table mall_brand \
--hive-import --hive-overwrite --hive-table aggregate_data.mall_brand --fields-terminated-by '\t' --hive-partition-key inputperiod --hive-partition-value 2017-03-16 \
--incremental append --check-column CreatedDtm --last-value '2017-03-15 00:00:01'
注意lastValue方式根据sqoop新旧版本不同参数
--incremental lastmodified -check-column (高)
--incremental append --check-column (低)
导出数据
sqoop export --connect jdbc:mysql://192.168.7.22:3306/bigdata_qu?characterEncoding=utf-8 --username inputuser --password inputpass --table fact_aggregate_useractivity --export-dir /user/hive/warehouse/aggregate_data.db/fact_aggregate_useractivity/inputperiod=$partition --input-fields-terminated-by '\001' --input-lines-terminated-by '\n' --input-fields-terminated-by '\t' --input-null-string '\\N' --input-null-non-string '\\N'