HyperSQL (HSQLDB) 显式共享(读)锁语法

HyperSQL (HSQLDB) explicit shared (read) lock syntax

根据 HSQLDB documentation,有两个 select-for-updating 指令:

If the SQL qualifier, FOR UPDATE is used, then all the updatable columns of the result set become updatable.

If a cursor is declared with FOR READ ONLY, then it is not updatable.

In HSQLDB, if FOR READ ONLY or FOR UPDATE is not used then all the updatable columns of the result set become updatable. This relaxes the SQL standard rule that in this case limits updatability to only simply updatable SELECT statements (where all columns are updatable).

如果 FOR UPDATE 使用独占(写)锁,FOR READ ONLY 指令是否使用共享(读)锁?

锁取决于事务模型。 LOCKS 和 MVLOCKS 模型在使用 FOR UPDATE 时锁定 table 以进行写入。当使用 FOR READ ONLY 时,他们锁定 table 以供读取。 MVCC 模型根本不锁定 table。