一、从msyql导入到hive表中
创建hive表
sqoop import --connect --username --password --query " SELECT * FROM User_LoginHistory.User_OnlineHistory_total WHERE LoginTime>='2013-01-01' and LoginTime<'2013-01-01 00:01:00' and \$CONDITIONS" -m 1 --fields-terminated-by '\t' --target-dir /user/root/bh_base_data/login --hive-import --hive-drop-import-delims --hive-table bhdp_base_data.login --create-hive-table
追加模式导入hive表
sqoop import --connect --username --password --append --query "SELECT * FROM User_LoginHistory.User_OnlineHistory_total WHERE LoginTime>='2013-01-01' and LoginTime<'2013-1-3' and \$CONDITIONS " -m 1 --fields-terminated-by '\t' --target-dir /user/hive/warehouse/bhdp_base_data.db/login
#!/bin/sh
tableNameList='DimAccountStatus DimAdInvestment DimAge DimAuthCategory DimAuthCheckStatus DimChannel DimCreditedById5 DimCreditedByMobile DimDate DimDegree DimGender D
imGeography DimHasMainPhoto DimHousing DimIncome DimInsign DimLoveStatus DimLoveType DimMarriage DimMergedDegree DimMergedHousing DimMergedIncome DimNewDegree DimNewHo
using DimNewIncome DimOrderStatus DimPhotoCheckStatus DimPlatform DimService DimTime DimUserIdType'
for tableName in ${tableNameList}
do
sqoop import --connect 'jdbc:mysql://172.16.4.113:3307/?useUnicode=true&characterEncoding=utf8' --username '***' --password '***' --query " SELECT * FR
OM bhdw.${tableName} where \$CONDITIONS" -m 1 --fields-terminated-by '\t' --target-dir /user/root/lmj_temp --hive-table bhdw.${tableName} --hive-import --hive-drop-i
mport-delims --null-non-string '\\N' --null-string '\\N' --hive-overwrite --create-hive-table
done
二、从sqlserver导入到hive表中
for tableName in ${tableNameList}
do
sqoop import --connect "jdbc:sqlserver://172.16.3.190;username=***;password=***;database=BHDW" --query " SELECT * FROM ${tableName} where \$CONDITIONS" -m 1 --fields-terminated-by '\t' --target-dir /user/root/lmj_temp --hive-import --hive-overwrite --hive-drop-import-delims --null-non-st
ring '\\N' --null-string '\\N' --hive-table bhdw.${tableName}
done