select-for-update

When to use SELECT … FOR UPDATE?

安稳与你 提交于 2019-11-26 08:40:54
问题 Please help me understand the use-case behind SELECT ... FOR UPDATE . Question 1 : Is the following a good example of when SELECT ... FOR UPDATE should be used? Given: rooms[id] tags[id, name] room_tags[room_id, tag_id] room_id and tag_id are foreign keys The application wants to list all rooms and their tags, but needs to differentiate between rooms with no tags versus rooms that have been removed. If SELECT ... FOR UPDATE is not used, what could happen is: Initially: rooms contains [id = 1]