开发者

oracle db lock issue, commit

开发者 https://www.devze.com 2022-12-19 03:54 出处:网络
This is oracle 10g. If I issue a开发者_如何学Pythonn update on a table from sqlplus but do not commit, then in another session update the same row and try to commit, it just hangs until I commit the f

This is oracle 10g. If I issue a开发者_如何学Pythonn update on a table from sqlplus but do not commit, then in another session update the same row and try to commit, it just hangs until I commit the first one. I know some would argue it's the locking mechanism but the application we have does the same thing and users are being blocked.

Whats the best way to avoid this issue?


Instead of just trying the update, you can issue a lock with the NOWAIT option, e.g.

SELECT * FROM mytable
WHERE xxx
FOR UPDATE NOWAIT;

If the row is locked by another user, Oracle will immediately raise ORA-00054: resource busy and acquire with NOWAIT specified.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号