[Author]: Kwu
Sqoop importing the relational library to update the federated primary key, import the data from hive into the relational library, if the Relational library table has a federated primary key, and you need to update the original data with the newly imported data.
1. Create a relational library table
CREATE TABLEtest123 (id INT not null,name VARCHAR (+) not null,age int,primary KEY (ID, name)) Engine=myisam DEFAULT CHARSET =utf8
2. Create Hive Table
drop table Default.test123;create table default.test123 ( ID int, name string, age int) ROW FORMAT Delimited fields terminated by ' \ t ' STORED as textfile;
To import test data:
Insert Overwrite table default.test123 Select 1, ' Bill ', 5 from default.kwu_test limit 1;
3. Sqoop Import MySQL Database
Sqoop export --connect jdbc:mysql://10.130.2.245:3306/test--update-key "Id,name" --username Kwu -- Password ' java.netphp ' --table test123 --fields-terminated-by ' \ t '--columns "Id,name,age"--export-dir/hive /warehouse/test123
Description: Key--update-key Specifies the value of the Federated primary key
To modify the test data:
Insert Overwrite table default.test123 Select 1, ' Bill ', 6 from default.kwu_test limit 1;
View the MySQL database in which age has been modified to 6.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Resolve an issue where the Sqoop import relationship Library updates the Federated primary key