不能使用--staging-table 参数
只有两种模式
更新
更新和插入
这个参数必须要加
-- --identity-insert
--hive建表
create table if not exists test.student(
id int,
name string,
score int,
home string
)
row format delimited fields terminated by '\t';
--sql server建表
create table student(
id bigint,
name varchar(255),
score bigint,
home varchar(255)
);
--测试脚本 update 成功
sqoop export \
--connect 'jdbc:sqlserver://al-node3:1433;database=test' \
--username sa \
--password Esliink123 \
--table student \
--columns "id,name,score,home" \
--export-dir /user/hive/warehouse/test.db/student \
--update-mode updateonly \
--update-key id \
--input-null-string '\\N' \
--input-null-non-string '\\N' \
--input-fields-terminated-by '\t' \
--fields-terminated-by ',' \
-- --identity-insert
--测试脚本 update and insert 成功
sqoop export \
--connect 'jdbc:sqlserver://al-node3:1433;database=test' \
--username sa \
--password Esliink123 \
--table student \
--columns "id,name,score,home" \
--export-dir /user/hive/warehouse/test.db/student \
--update-mode allowinsert \
--update-key id \
--input-null-string '\\N' \
--input-null-non-string '\\N' \
--input-fields-terminated-by '\t' \
--fields-terminated-by ',' \
-- --identity-insert