Use the SELECT FOR UPDATE statement to lock query results

2023-08-18 09:26:34  Updated

OceanBase supports multiversion concurrency control (MVCC). Data reads are snapshot reads, which do not block writes. If used in a specific way, the SELECT statements can block writes. Example:

obclient> select w_name, w_ytd, w_tax from ware where w_id=1 for update;
+------------+---------+--------+
| w_name     | w_ytd   | w_tax  |
+------------+---------+--------+
| n1P4zYo8OH | 1200.00 | 0.1868 |
+------------+---------+--------+
1 row in set (0.01 sec)

Contact Us