SQLite - UPSERT *not* INSERT or REPLACE

后端 未结 18 2588
猫巷女王i
猫巷女王i 2020-11-21 23:53

http://en.wikipedia.org/wiki/Upsert

Insert Update stored proc on SQL Server

Is there some clever way to do this in SQLite that I have not thought of?

18条回答
  •  迷失自我
    2020-11-22 00:11

    Updates from Bernhardt:

    You can indeed do an upsert in SQLite, it just looks a little different than you are used to. It would look something like:

    INSERT INTO table_name (id, column1, column2) 
    VALUES ("youruuid", "value12", "value2")
    ON CONFLICT(id) DO UPDATE 
    SET column1 = "value1", column2 = "value2"
    

提交回复
热议问题