Is it possible to use a LOAD DATA INFILE type command to UPDATE rows in the db?

后端 未结 2 1689
迷失自我
迷失自我 2021-02-03 13:38

Pseudo table:

 | primary_key | first_name | last_name | date_of_birth |
 | 1           | John Smith |           | 07/04/1982    |

At the moment

2条回答
  •  既然无缘
    2021-02-03 14:06

    In this situation I usually LOAD DATA INFILE to a temp table with identical structure. Then I do INSERT with ON DUPLICATE KEY UPDATE from the temp table to the real table. This allows for data type checking without wrecking your real table; it's relatively quick and it doesn't require fiddling with your .csv file.

提交回复
热议问题