#Oracle的连接字符串,其中包含了Oracle的地址,SID,和端口号 CONNECTURL=jdbc:oracle:thin:@20.135.60.21:1521:DWRAC2 #使用的用户名 ORACLENAME=kkaa #使用的密码 ORACLEPASSWORD=kkaa123 #需要从Oracle中导入的表名 oralceTableName=tt #需要从Oracle中导入的表中的字段名 columns=AREA_ID,TEAM_NAME #将Oracle中的数据导入到HDFS后的存放路径 hdfsPath=apps/as/hive/$oralceTableName #执行导入逻辑。将Oracle中的数据导入到HDFS中 sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --num-mappers 1 --table $oralceTableName --columns $columns --fields-terminated-by '\001'
sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --m 1 --table $oralceTableName --columns $columns --fields-terminated-by '\001' --where "data_desc='2011-02-26'"
sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --m 4 --table $oralceTableName --columns $columns --fields-terminated-by '\001' --where "data_desc='2011-02-26'"
ERROR tool.ImportTool: Error during import: No primary key could be found for table creater_user.popt_cas_redirect_his. Please specify one with --split-by or perform a sequential import with '-m 1'.
select max(id) as max, select min(id) as min from table [where 如果指定了where子句];
select * from table where 0 <= id < 250; select * from table where 250 <= id < 500; select * from table where 500 <= id < 750; select * from table where 750 <= id < 1000;
select min(ds_name), max(ds_name) from creater_user.popt_cas_redirect_his where data_desc='2011-02-26'
select min(CLIENTIP), max(CLIENTIP) from creater_user.popt_cas_redirect_his where data_desc='2011-02-26'
sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --m 12 --split-by CLIENTIP --table $oralceTableName --columns $columns --fields-terminated-by '\001' --where "data_desc='2011-02-26'"
sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --m 1 --table $oralceTableName --columns $columns --fields-terminated-by '\001' --where "data_desc='2011-02-26' logtime<10:00:00" sqoop import --append --connect $CONNECTURL --username $ORACLENAME --password $ORACLEPASSWORD --target-dir $hdfsPath --m 1 --table $oralceTableName --columns $columns --fields-terminated-by '\001' --where "data_desc='2011-02-26' logtime>=10:00:00"