Beruflich Dokumente
Kultur Dokumente
BY DAVIN.J.ABRAHAM
What is Sqoop
import
--connect
jdbc:mysql://airawat-mySqlServer-node/employees
--username
myUID
--password
myPwd
#
#All other commands should be specified in the command line
Options File - Command
The command
d009,Customer Service
d005,Development
d002,Finance
d003,Human Resources
d001,Marketing
d004,Production
d006,Quality Management
d008,Research
d007,Sales
Import all Rows But Column Specific
--username MyUID \
--password myPWD \
--table employees_export \
--staging-table employees_exp_stg \
--clear-staging-table \
-m 4 \
--export-dir /user/airawat/sqoop-mysql/Employees
.
.
.
13/06/04 09:54:18 INFO manager.SqlManager: Migrated 300024
records from `employees_exp_stg` to `employees_export`
Results of Export
Results
Sqoop command:
Next, we will export the same data to the same table, and see if the hire date is
updated.
$ sqoop export \
--connect jdbc:mysql://airawat-mysqlserver-node/employees \
--username myUID \
--password myPWD \
--table employees_export \
--direct \
--update-key emp_no \
--update-mode updateonly \
--export-dir /user/airawat/sqoop-mysql/Employees
It Worked!
. Results:
mysql> select count(*) from employees_export where hire_date
is null;
+----------+
| count(*) |
+----------+
| 0 |
+----------+
1 row in set (0.22 sec)
Export in upsert (Update+Insert)
mode
Upsert= insert if does not exist,
update if exists.
Upsert Command
sqoop export \
--connect jdbc:mysql://airawat-mysqlserver-node/employees \
--username myUID \
--password myPWD \
--table employees_export \
--update-key emp_no \
--update-mode allowinsert \
--export-dir /user/airawat/sqoop-mysql/Employees
Exports may Fail due to