在sqoop语句中,是否有一项规定我们只能从oracle端选择特定列?
sqoop import --target-dir /tmp/customers --query "SELECT * FROM schema1.customers where item>=1234 and \$CONDITIONS" --connect jdbc:oracle:thin:@server1.companyxyz.com:4567/prod --username xyz --password xyz --hive-drop-import-delims -m 8 --fields-terminated-by , --escaped-by \\ --split-by cust_id
sqoop import --target-dir /tmp/customers --query "SELECT cust_id, name, address, date, history, occupation FROM schema1.customers where item>=1234 and \$CONDITIONS" --connect jdbc:oracle:thin:@server1.companyxyz.com:4567/prod --username xyz --password xyz --hive-drop-import-delims -m 8 --fields-terminated-by , --escaped-by \\ --split-by cust_id
答案 0 :(得分:5)
你可以使用--columns --table --where子句来实现它。样品如下:
sqoop import
--connect jdbc:oracle:thin:@server1.companyxyz.com:4567/prod/DATABASE=schema1
--username xyz
--password xyz
--table customers
--columns cust_id, name, address, date, history, occupation
--where item>=1234
--target-dir /tmp//customers
--m 8
--split-by cust_id
--fields-terminated-by ,
--escaped-by \
--hive-drop-import-delims
--map-column-java
cust_id=string, name=string, address=string, date=string, history=string, occupation=string
答案 1 :(得分:0)
我怀疑SELECT cust_id, name, address, date, history, occupation FROM schema1.customers where item>=1234
不正确。我尝试了所有可能的场景。尝试在数据库中运行它。在运行第二个语句之前,还要删除目录/ tmp / customers。您也应该粘贴错误。
sqoop import \
--connect "jdbc:mysql://sandbox.hortonworks.com:3306/retail_db" \
--username=retail_dba \
--password=hadoop \
--query "select department_id, department_name from departments where \$CONDITIONS" \
--target-dir /user/root//testing \
--split-by department_id \
--outdir java_files \
--hive-drop-import-delims \
-m 8 \
--fields-terminated-by , \
--escaped-by '\'