In SQL, is UPDATE always faster than DELETE+INSERT?

前端 未结 15 2214
梦谈多话
梦谈多话 2020-11-29 20:01

Say I have a simple table that has the following fields:

  1. ID: int, autoincremental (identity), primary key
  2. Name: varchar(50), unique, has unique index<
15条回答
  •  猫巷女王i
    2020-11-29 20:43

    The question of speed is irrelevant without a specific speed problem.

    If you are writing SQL code to make a change to an existing row, you UPDATE it. Anything else is incorrect.

    If you're going to break the rules of how code should work, then you'd better have a damn good, quantified reason for it, and not a vague idea of "This way is faster", when you don't have any idea what "faster" is.

提交回复
热议问题