Skip to content
SQLSimplified
BackendQuestion 35 of 52

Optimistic Locking

Problem

Two admins are editing the same wiki page. If they both click save at the same time, the slower one overwrites the faster one's changes (Lost Update). You add a version column to prevent this. Simulate optimistic locking: Write an UPDATE on accounts to set balance = 500, version = 2 WHERE id = 1 AND version = 1.

Database Schema

This problem acts as a scratchpad. You will write your own DDL/DML or conceptual queries, so there is no predefined schema.

Try It

Loading playground environment...

Hint

Solution