Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Is it possible to import csv file data into oracle database using sqoop

avatar
New Contributor

I want to load a csv data into oracle database table using sqoop

4 REPLIES 4

avatar
Master Guru

try this I found here

http://ingest.tips/2015/02/06/use-sqoop-transfer-csv-data-local-filesystem-relational-database/

Using Sqoop1, the data above can be exported to the children table with the following query:

sqoop export -fs local -jt local --connect jdbc:mysql://example.com/example --username example --password example --table test --export-dir file:///tmp/data

NOTES

  • -fs local and -jt local are used to reference the local file system and make sqoop run a local MapReduce job
  • The URI prefix file:/// is useful for accessing the local file system
  • /tmp/data/sample.csv should have the same number of columns as the table and map to the appropriate columns based on order
  • You may need to provide -libjars if you’re getting ClassNotFound exceptions.

avatar
Expert Contributor

I don't think that Sqoop supports importing from Hive or exporting to Hive. It is intended as a bridge between Hive and RDBMS. However, you should be able to do,

From within hive, run the following command:

insert overwrite local directory '/home/user/staging' row format delimited fields terminated by','select*from table;

This command will save the results of the select on the table to a file on your local system, then export csv to Oracle.

avatar
New Contributor

Hi Sunile,

Yes i have tried with MySQL but want to know if its possible to migrate the data to Oracle DB using Sqoop

avatar

Yes, its possible to import data between Hadoop datastores (HDFS, Hive, HBase) and Oracle. Here is a sample command for import data from HDFS to Oracle.

sqoop export --connect jdbc:oracle:thin:@oradb.example.com:1521:ORCL --table bar --username user --password passwd --export-dir /user/test/data

Above command assumes that the csv data file to be exported into Oracle is in the HDFS folder /user/test/data and the table "bar" exists in Oracle. Also the csv data and its column sequence matches with that of the Oracle table.