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

后端 未结 2 1662
迷失自我
迷失自我 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

    No. While LOAD DATA INFILE has a REPLACE option, it will actually replace the row in question - that is, delete the existing one and insert a new one.

    If you configure your LOAD DATA INFILE to only insert certain columns all others will be set to their default values, not to values they currently contain.

    Can you modify your CSV file to contain a bunch of UPDATE statements instead? Should be reasonably straightforward via some regex replaces.

提交回复
热议问题