MySQL bulk INSERT or UPDATE

前端 未结 5 2063
粉色の甜心
粉色の甜心 2020-12-01 06:32

Is there any way of performing in bulk a query like INSERT OR UPDATE on the MySQL server?

INSERT IGNORE ...

won\'t work, becau

5条回答
  •  鱼传尺愫
    2020-12-01 07:04

    If you were using Oracle or Microsoft SQL, you could use the MERGE. However, MySQL does not have a direct correlation to that statement. There is the single-row solution that you mentioned but, as you pointed out, it doesn't do bulk very well. Here is a blog post I found on the difference between Oracle and MySQL and how to do what Oracle does with MERGE in MySQL:

    http://blog.mclaughlinsoftware.com/2009/05/25/mysql-merge-gone-awry/

    It isn't a pretty solution and it probably isn't as full a solution as you would like, but I believe that is the best there is for a solution.

提交回复
热议问题