Search code examples
hadoopsqoop2

Sqoop export update only specified columns


As far as I know, we can update database using "--udate-key" argument. Which updates whole record for that key. we can either insert or update with "--update-mode allowinsert" or "--update-mode updateonly".

For example I have a file which consists of primary key and a column values which I have to update in a table where it has other columns too. My question is, can we update that particular column without updating those other columns in table? We must specify all the columns for --update-key argument right? is there any solution or work around for this?


Solution

  • Yes.
    By using "--update-key" and "columns" arguments. Example:
    $ sqoop export --connect jdbc:mysql://localhost/TGL --username root --password root --table staging --export-dir /sqoop/DB1_Result -m 1 -input-fields-terminated-by ","
    note: field specified in update-key must be in columns argument