Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import SQL Server table to HDFS

I am new to Hadoop and I have few queries regarding importing a table from SQL Server to hdfs using sqoop:

  1. How to import whole database into hadoop using sqoop and any other way.
  2. How can I import a single table which don't have primary key or is it possible to import SQL Server table which don't have primary key.
like image 649
sandybo Avatar asked May 09 '26 08:05

sandybo


2 Answers

  1. How to import whole database into hadoop using sqoop and any other way.

    You can use sqoop-import-all-tables to do that. Other way would be to write your own job using DBInputFormat.

  2. How can I import a single table which don't have primary key or is it possible to import SQL Server table which don't have primary key.

    You can use --split-by to specify a column other than primary key column.

like image 50
Tariq Avatar answered May 11 '26 22:05

Tariq


For the 2nd question-How can I import a single table which don't have primary key or is it possible to import SQL Server table which don't have primary key.

When the table we import does not have a primary key we need to specify in the commands as to how many mappers are to be used. this can be specified by the options "-m" or "--Split-by" in the sqoop import

e.g:

$ bin/sqoop import -connect jdbc:mysql://localhost:3306/db1 -username root -password password --table tableName --target-dir /user/tableName -m 1

like image 24
user2637464 Avatar answered May 11 '26 23:05

user2637464



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!