1.更新導出(updateonly模式)
1.1參數說明
-- update-key,更新標識,即根據某個字段進行更新,例如id,可以指定多個更新標識的字段,多個字段之間用逗號分隔。
-- updatemode,指定updateonly(默認模式),僅僅更新已存在的數據記錄,不會插入新紀錄。
1.2代碼
bin/sqoop export \
--connect jdbc:mysql://node-1:3306/userdb \
--username root --password hadoop \
--table updateonly \
--export-dir /updateonly_2/ \
--update-key id \
--update-mode updateonly
2.更新導出(allowinsert模式)
2.1參數說明
-- update-key,更新標識,即根據某個字段進行更新,例如id,可以指定多個更新標識的字段,多個字段之間用逗號分隔。
-- updatemod,指定allowinsert,更新已存在的數據記錄,同時插入新紀錄。實質上是一個insert & update的操作。
2.2代碼
bin/sqoop export \
--connect jdbc:mysql://node-1:3306/userdb \
--username root --password hadoop \
--table allowinsert \
--export-dir /allowinsert_2/ \
--update-key id \
--update-mode allowinsert