开发者

SQL DB2 Bulk update from csv

开发者 https://www.devze.com 2023-03-30 04:41 出处:网络
I get emailed an excel spreadsheet with 4 columns. The first column is (ID) and the 4th is the (Model#). Is there a way in DB2 to bulk update?

I get emailed an excel spreadsheet with 4 columns. The first column is (ID) and the 4th is the (Model#). Is there a way in DB2 to bulk update?

Something like

 开发者_JAVA技巧Update (Table) 
 set Model# = (Model#)
 where ID = (ID)

DB2 has Import, but not quite what I'm looking for.

 IMPORT FROM my_file.csv
 OF del
 METHOD P(2, 3, 5)
 INSERT INTO my_table(my_column_2, my_column_3, my_column_5)


4Did you read the documentation for the IMPORT command?

You can use INSERT_UPDATE to update rows where the primary key value matches the data in the CSV file:

IMPORT FROM my_file.csv
OF del
METHOD P(1, 4)
INSERT_UPDATE INTO my_table(my_column_1, my_column_4)

This assumes that my_column_1 is the primary key in the table…

0

精彩评论

暂无评论...
验证码 换一张
取 消