Previously we talked about sqoop import, now in this article, we will continue on the journey with sqoop export.
Sqoop Export Common Scenarios
1. export a Hive table to MySQL
| |
NOTE:
- The
--tableand--export-dirvariables are required for sqoop export. These specify the table to populate in the database, and the directory in HDFS that contains the source data.
2. export a Hive table and only update data in MySQL table
| |
NOTE:
- we can use
--update-mode updateonlyoption to specify that we just want to update existing records and we don’t want insert any new data to the MySQL table.--update-key column_namevariable is to specify the particular column_name that we use for updating existing data
3. export a Hive table and insert and update data in MySQL table
| |
NOTE
- Different with previous scenario, now we need to use
--update-mode allowinsertto tell sqoop that we are not only want to update existing data, but inserting new data to the MySQL table
4. export a Hive table and replace null characters
| |
NOTE:
- we can use
--input-fields-terminated-byoption to setup the input data delimiter in Hive. The default fields delimiter in Hive is\001. Similarly,--input-lines-terminated-byoption is to setup the lines delimiter and the Hive default value is “\n”. --input-null-stringoption is to replace all the null string-typed value to the character we want. Whilst,--input-null-non-stringoption is to replace all the null non-string-typed value.