Below are some sample commands to export and import operator in SQOOP to move data from relational databases (e.g., mysql is used here) to HDFS location
Export:
sqoop export --connect jdbc:mysql://mysqldb.****.****/database --table <table_name> --username ******* -password ****** -fields-terminated-by ',' -m 1 --export-dir <HDFS Path>
Import:
sqoop import --connect jdbc:mysql://mysqldb.******.****/MyDB --table customers --username ****** --password ****** --target-dir batch/sqoop/job1 -m 1
=> m =1 loads all data to single part file.
=> m= 5 loads data to 5 separate part files.
Extracts specific columns:
sqoop import --connect jdbc:mysql://mysqldb.edu.cloudlab.com/retail_db --table customers --username labuser --password edureka --target-dir batch/sqoop/job1 --columns “column1, column2” -m 1