Sqoop import part 1

Estimated reading: 2 minutes 370 views

Import data to HDFS directory

sqoop import \
–connect jdbc:mysql://localhost:3306/retail_db \
–username root \
–password password \
–table cardbase \
–target-dir hdfs://localhost:9000/user/username/scoop_import \
–m 1

Overwrite or Delete target directory before each sqoop import

sqoop import \
–connect jdbc:mysql://localhost:3306/retail_db \
–username root \
–password password \
–table cardbase \
–target-dir hdfs://localhost:9000/user/username/scoop_import \
–m 1

Sqoop only required columns

sqoop import \
–connect jdbc:mysql://gator4148.hostgator.com/retail_db \
–username root \
–password password \
–table cardbase \
–columns “card_number, credit_limit, cust_id” \
–target-dir /user/password/sqoop/cardbase_with_columns \
–m 1

How to append the data in same directory

sqoop import \
–connect jdbc:mysql://gator4148.hostgator.com/retail_db \
–username root \
–password password \
–table cardbase \
–target-dir /user/password/sqoop/cardbase \
–append \
–m 1

sqoop import from with primary key tables.

sqoop import \
-Dorg.apache.sqoop.splitter.allow_text_splitter=true \
–connect jdbc:mysql://gator4148.hostgator.com/retail_db \
–username root \
–password password \
–table CustomerBase_with_primarykey \
–target-dir /user/password/sqoop/customer_base_with_pk \
–delete-target-dir

How to append the data in same directory

sqoop import \
–connect jdbc:mysql://gator4148.hostgator.com/retail_db \
–username root \
–password password \
–table cardbase \
–target-dir /user/password/sqoop/cardbase \
–append \
–m 1

Leave a Comment

CONTENTS