10

It is possible to export data from HDFS to RDBMS table using Sqoop. But it seems like we need to have existing table.

Is there some parameter to tell Sqoop do the 'CREATE TABLE' thing and export data to this newly crated table?

If yes, is it going to work with Oracle?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Bohdan
  • 16,531
  • 16
  • 74
  • 68

3 Answers3

10

I'm afraid that Sqoop do not support creating tables in the RDBMS at the moment. Sqoop uses the table in RDBMS to get metadata (number of columns and their data types), so I'm not sure where Sqoop could get the metadata to create the table for you.

Jarek Jarcec Cecho
  • 1,736
  • 1
  • 10
  • 13
3

You can actually execute arbitrary SQL queries and DDL via sqoop eval, at least with MySQL and MSSQL. I'd expect it to work with Oracle as well. MSSQL example:

sqoop eval --connect 'jdbc:sqlserver://<DB SERVER>:<DB PORT>;
database=<DB NAME>'  --query "CREATE TABLE..."
--username <USERNAME> -P
Paul Back
  • 1,269
  • 16
  • 23
  • 2
    Sqoop user guide mentions that eval should not be used in production workflows - "The eval tool is provided for evaluation purpose only. You can use it to verify database connection from within the Sqoop or to test simple queries. It’s not suppose to be used in production workflows." – Kumar Vaibhav Jul 13 '17 at 17:32
0

I noticed you use Oracle too. Certain sqoop vendor-specific sqoop connectors support that, including Oracle. Sqoop's Oracle direct connect mode has option to do that

https://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html#_create_oracle_tables

24.8.5.4. Create Oracle Tables

-Doraoop.template.table=TemplateTableName

Creates OracleTableName by replicating the structure and data types of TemplateTableName. TemplateTableName is a table that exists in Oracle prior to executing the Sqoop command.

ps. You'll have to use --direct sqoop export option to activate sqoop direct mode = 'Data Connector for Oracle and Hadoop' (aka OraOOP - older name).

Community
  • 1
  • 1
Tagar
  • 13,911
  • 6
  • 95
  • 110