Questions tagged «select-for-update»

2
何时使用SELECT…FOR UPDATE?
请帮助我了解后面的用例SELECT ... FOR UPDATE。 问题1:以下是何时SELECT ... FOR UPDATE应使用的一个很好的例子吗? 鉴于: 房间[id] 标签[ID,名称] room_tags [room_id,tag_id] room_id和tag_id是外键 该应用程序要列出所有房间及其标签,但是需要区分没有标签的房间和已删除的房间。如果不使用SELECT ... FOR UPDATE,则可能发生以下情况: 原来: 房间包含 [id = 1] 标签包含 [id = 1, name = 'cats'] room_tags包含 [room_id = 1, tag_id = 1] 线程1: SELECT id FROM rooms; returns [id = 1] 线程2: DELETE FROM room_tags …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.