如何在 Sqoop 导入命令中指定 Oracle 数据库模式名称

How to specify Oracle database schema name in Sqoop import command

我有一个 oracle schema/user U1(密码 P1),其中包含 table T1。 还有另一个 oracle schema/user U2(密码 P2)对 table U1.T1.

具有读取权限

如何使用凭证导入 T1 U2/P2。以下命令似乎不起作用。

sqoop import --connect jdbc:oracle:thin:@//localhost:1521/xe --username U2 --password P2 -m 1 --table U1.T1

登录 运行 --verbose 标志

16/10/19 20:52:23 DEBUG manager.OracleManager: Using column names query: SELECT t.* FROM T1 t WHERE 1=0
16/10/19 20:52:23 DEBUG manager.SqlManager: Execute getColumnInfoRawQuery : SELECT t.* FROM T1 t WHERE 1=0
16/10/19 20:52:23 DEBUG manager.OracleManager: Creating a new connection for jdbc:oracle:thin:@//localhost:1521/xe, using username:U2
16/10/19 20:52:23 DEBUG manager.OracleManager: No connection paramenters specified. Using regular API for making connection.
16/10/19 20:52:24 INFO manager.OracleManager: Time zone has been set to GMT
16/10/19 20:52:24 DEBUG manager.SqlManager: Using fetchSize for next query: 1000
16/10/19 20:52:24 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM TABLE_NAME t WHERE 1=0
16/10/19 20:52:24 DEBUG manager.SqlManager: Found column xxxxxxxxxx of type [2, 19, 0]
16/10/19 20:52:24 DEBUG manager.SqlManager: Found column xxxxxxxxxxxxx of type [12, 36, 0]
16/10/19 20:52:24 DEBUG manager.SqlManager: Found column xxxxxxxxxxxxx of type [-9, 512, 0]
....
16/10/19 20:52:24 DEBUG manager.OracleManager$ConnCache: Caching released connection for jdbc:oracle:thin:@//localhost:1521/xe/U2
16/10/19 20:52:24 ERROR tool.ImportTool: Imported Failed: There is no column found in the target table T1. Please ensure that your table name is correct.

您可能需要使用类似这样的东西sqoop import -–connect jdbc:oracle:thin:system/system@localhost:1521:xe

问题在于 Table 名称和用户名的大小写敏感性。

根据 sqoop docs,

  1. Specify the user name, which Sqoop is connecting as, in upper case (unless it was created with mixed/lower case within quotes).

  2. Specify the table name, which you are working with, in upper case (unless it was created with mixed/lower case within quotes).