游标稳定性隔离

带有游标稳定隔离的阅读器要求当前取得的行上有一个共享锁定。这个操作确保,在当前用户取回一个新行之前,其他用户不能更新该行。

图 1 中游标的示例中,在 fetch a row 处,数据库服务器释放上一行的锁,并对正在访存的行放置锁。在 close the cursor 处,服务器释放最后一行的锁。

图: 为游标稳定性加上的锁定

set isolation to cursor stability
declare cursor for SELECT * FROM customer
open the cursor
while there are more rows
       fetch a row
   do work
end while
close the cursor

如果不使用游标取得数据,“游标稳定”隔离就与“已落实读取”的行为一致。 实际上没有加上锁定。