Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 02-12-2016 04:12 PM
Hi,
I am new to sqoop and trying to write few simple sqoop scripts. I am trying to query a table with where clause condition. When I give the where clause condition it's failing. Here is my simple script:
sqoop import \
--connect jdbc:mysql://localhost/test \
--username sat \
-P \
--query 'select emp_no,salary from salaries where salary >8000' \
--target-dir /user/ \
--m 1
I went through sqoop documentation and it was mentioned that I should use $CONDITIONS , but here my question is, if I use this parameter then , where I can specify my where clause condition. Please help me on the same.
Thanks,
Satish.
Created 02-12-2016 04:18 PM
See this tutorial http://www.tutorialspoint.com/sqoop/sqoop_import.htm
sqoop import \ --connect jdbc:mysql://localhost/userdb \--username root \ --table emp_add \ --m 1 \ --where“city =’sec-bad’” \ --target-dir /wherequery
Created 06-08-2016 08:36 AM
@Roberto Sancho
When you use double quotes for enclosing character, you have to escape '$' such as '\$'.
So, please try:
--query "SELECT (....) WHERE \$CONDITIONS AND (...)"
Created 11-15-2017 05:29 AM
Hi @Roberto Sancho
sqoop import -D oraoop.disabled=true \
--connect jdbc:oracle:thin:@HOSTNAME:2521/CIP_BATCH \
--username=U029550 \
--password=Mayo2016 \
--query "SELECT ID_INTERNO_PE,MI_FECHA_FIN_MES,COD_NRBE_EN,COD_LINEA,ID_GRP_PD,MI_NUM_TOT_AC_ACT,MI_NUM_AC_SUS,MI_SDO_AC_P,MI_NUM_AC_P,MI_DIA_AC_P,MI_INT_DEV_ACR_D,MI_INT_DEV_DEU_D,MI_COMIS_APL_D,MI_TOT_MOV_D,MI_TOT_MOV_H,MI_TOT_IMP_MOV_D,MI_TOT_IMP_MOV_ FROM RDWC01.MI_CLTE_ECO_GEN WHERE \$CONDITIONS AND COD_RL_PERS_AC = 01 AND COD_LINEA in ('01','03','04','05') AND COD_NRBE_EN = '3159' AND TRUNC(MI_FECHA_FIN_MES) >=TO_DATE('2010-01-01', 'YYYY-MM-DD')" \
--split-by MI_NUM_TOT_AC_ACT \
--fetch-size=50000
This query works fine 🙂