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

前端 未结 5 1030
轮回少年
轮回少年 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 21:55

    In Oracle, the SELECT ... FOR UPDATE has no effect on a non-existent row (the statement simply raises a No Data Found exception). The INSERT statement will prevent a duplicates of unique/primary key values. Any other transactions attempting to insert the same key values will block until the first transaction commits (at which time the blocked transaction will get a duplicate key error) or rolls back (at which time the blocked transaction continues).

提交回复
热议问题