SQLite “INSERT OR REPLACE INTO” vs. “UPDATE … WHERE”

后端 未结 4 1934
暖寄归人
暖寄归人 2020-11-29 22:24

I\'ve never seen the syntax INSERT OR REPLACE INTO names (id, name) VALUES (1, \"John\") used in SQL before, and I was wondering why it\'s better than UPD

4条回答
  •  眼角桃花
    2020-11-29 22:39

    UPDATE will not do anything if the row does not exist.

    Where as the INSERT OR REPLACE would insert if the row does not exist, or replace the values if it does.

提交回复
热议问题