Import examples:
A basic import of a table named EMPLOYEES in the test database:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES
A basic import requiring a login:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --username SomeUser -P Enter password: (hidden)
Selecting specific columns from the EMPLOYEES table:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --columns "employee_id,first_name,last_name,job_title"
Controlling the import parallelism (using 8 parallel tasks):
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ -m 8
Storing data in SequenceFiles, and setting the generated class name to com.test.Employee:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --class-name com.test.Employee --as-sequencefile
Specifying the delimiters to use in a text-mode import:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --fields-terminated-by '\t' --lines-terminated-by '\n' \
Importing the data to Hive:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --hive-import
Importing only new employees:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --where "start_date > '2010-01-01'"
Changing the splitting column from the default:
$ sqoop import --connect jdbc:mysql://db.foo.com/test --table EMPLOYEES \ --split-by dept_id
Performing an incremental import of new data, after having already imported the first 100,000 rows of a table:
$ sqoop import --connect jdbc:mysql://db.test.com/test1 --table sometable \ --where "id > 100000" --target-dir /incremental_dataset --append
An import of a table named EMPLOYEES in the test database that uses validation to validate the import using the table row count and number of rows copied into HDFS.
$ sqoop import --connect jdbc:mysql://db.foo.com/test \ --table EMPLOYEES --validate