You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Sqoop --where多条件过滤配置求助(Oracle到Hadoop数据导入)

解决方法

直接在原有的--where参数中用AND拼接新增的过滤条件即可,无需改用--query参数。

原脚本片段示例

sqoop import \
  --connect jdbc:oracle:thin:@//oracle-host:1521/ORCL \
  --username your_username \
  --password your_password \
  --table your_oracle_table \
  --where "date='2024-05-20'" \
  --target-dir /hdfs/path/your_hadoop_table \
  --delete-target-dir

修改后的脚本片段示例

sqoop import \
  --connect jdbc:oracle:thin:@//oracle-host:1521/ORCL \
  --username your_username \
  --password your_password \
  --table your_oracle_table \
  --where "date='2024-05-20' AND status='Active'" \
  --target-dir /hdfs/path/your_hadoop_table \
  --delete-target-dir

额外说明

如果date字段是Oracle的日期类型,需确保日期格式匹配Oracle的要求,比如可以用TO_DATE函数规范格式:

--where "date=TO_DATE('2024-05-20','YYYY-MM-DD') AND status='Active'"

内容的提问来源于stack exchange,提问作者aruntheimperfect

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 10:24:45