How to use a specified Hive database when using Sqoop import
Asked Answered
R

3

5
sqoop import --connect jdbc:mysql://remote-ip/db --username xxx --password xxx --table tb --hive-import

The above command imports table tb into the 'default' Hive database.

Can I use other database instead?

Representationalism answered 21/3, 2013 at 10:3 Comment(0)
A
11

Off the top of my head i recall you can specify --hive-table foo.tb

where foo is your hive database and tb is your hive table.

so in your case it would be:

sqoop import --connect jdbc:mysql://remote-ip/db --username xxx --password xxx --table tb --hive-import --hive-table foo.tb

As a footnote, here is the original jira issue https://issues.apache.org/jira/browse/SQOOP-322

Allonym answered 21/3, 2013 at 18:54 Comment(0)
D
10

Hive database using Sqoop import:

sqoop import --connect jdbc:mysql://localhost/arun --table account --username root --password root -m 1 --hive-import **--hive-database** company **--create-hive-table --hive-table** account --target-dir /tmp/customer/ac

Dipteran answered 1/2, 2016 at 7:31 Comment(2)
strange: --hive-database seems to be an undocumented option [sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html] but it works for me as exactly expected. My sqoop-version on cloudera returns: INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.13.0 Sqoop 1.4.6-cdh5.13.0Surprisal
This should be the accepted answer. As in certain cases, we need to specify the database name.Holsinger
B
1

You can specify the database name as a part of the --hive-table parameter, e.g. "--hive-table foo.tb".

There is a new request to add a special parameter for the database that is being tracked: SQOOP-912.

Barajas answered 24/3, 2013 at 1:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.