Does “select for update” prevent other connections inserting when the row is not present

前端 未结 5 1079
轮回少年
轮回少年 2020-12-30 21:24

I\'m interested in whether a select for update query will lock a non-existent row.

e.g.

Table FooBar with two columns, foo and bar, foo has a un

5条回答
  •  灰色年华
    2020-12-30 22:03

    SQL Server only has the FOR UPDATE as part of a cursor. And, it only applies to UPDATE statements that are associated with the current row in the cursor.

    So, the FOR UPDATE has no relationship with INSERT. Therefore, I think your answer is that it's not applicable in SQL Server.

    Now, it may be possible to simulate the FOR UPDATE behavior with transactions and locking strategies. But, that may be more than what you're looking for.

提交回复
热议问题