简体   繁体   English

使用 --schema 参数将 Sqoop 导出到 postgres

[英]Sqoop export to postgres with --schema argument

Is there any way to mention different schema when exporting data to postgresql using Sqoop?使用 Sqoop 将数据导出到 postgresql 时,有什么方法可以提及不同的模式吗?

Based on the URL http://sqoop.apache.org/docs/1.4.4/SqoopUserGuide.html , I need to use -- --schema which is pretty weird, well it doesn't work.基于 URL http://sqoop.apache.org/docs/1.4.4/SqoopUserGuide.html ,我需要使用-- --schema这很奇怪,但它不起作用。

I tried to use --schema as well, but still same result.我也尝试使用--schema ,但结果仍然相同。 -- --schema works with list-tables command but not with export command. -- --schema适用于 list-tables 命令,但不适用于export命令。

Any helps will be highly appreciated.任何帮助将不胜感激。

It finally worked.它终于奏效了。 In order to use "-- --schema", we need to provide that option at the very end, not in the middle.为了使用“---schema”,我们需要在最后提供该选项,而不是在中间。 So this one will work:所以这个会起作用:

--connect jdbc:postgresql://xxx/abcd --username xxx --password xxx --table xxx --input-fields-terminated-by '\001' --input-lines-terminated-by '\n' --num-mappers 8 --input-null-string '\\N' --input-null-non-string '\\N' --export-dir /user/hadoop/xxx -- --schema stage

Whereas this one will not work:而这个不起作用:

--connect jdbc:postgresql://xxx/abcd --username xxx --password xxx  -- --schema stage --table xxx --input-fields-terminated-by '\001' --input-lines-terminated-by '\n' --num-mappers 8 --input-null-string '\\N' --input-null-non-string '\\N' --export-dir /user/hadoop/xxx

By default you might be thinking to put schema name before mentioning table name, but that will not work.默认情况下,您可能会考虑在提及表名之前放置模式名称,但这是行不通的。 It would have been great if this information was included in the Sqoop document.如果此信息包含在 Sqoop 文档中,那就太好了。

Yes using the -- --schema at the end of the sqoop export statement worked fine.是的,在 sqoop 导出语句末尾使用 -- --schema 工作正常。

By default the the schema "dbo" is picked up in sqoop export.默认情况下,模式“dbo”在 sqoop 导出中被选取。

The --schema parameter must be separated from the rest of the parameters with an extra set of dashes (ie -- ) and the --schema parameter must come last. --schema参数必须用一组额外的破折号(即-- )与其余参数分开,并且--schema参数必须放在最后。

Refer: Sqoop Export Cookbook参考: Sqoop 导出手册

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM