Perform Sqoop Import of orders - --table and --target-dir


Let us see how we can perform simple import using sqoop import with table and target-dir.

  • We need to use connect, username and password to connect to the database using sqoop import.
  • We need to specify database table name using –table.
  • Target location can be specified using target-dir.
  • Data will be read from retail_db.orders and written to HDFS location specified using target-dir.
  • If the target directory exists, by default import will fail.

Here is the example to import retail_db.orders to /user/training/sqoop_import/retail_db/orders

sqoop import \
  --connect "jdbc:mysql://" \
  --username retail_user \
  --password itversity \
  --table orders \
  --target-dir /user/training/sqoop_import/retail_db/orders