DB2 for z/OS 的隔离级别是否与 Oracle 中的 READ ONLY 类似?

Does DB2 for z/OS have isolation level similar to READ ONLY in Oracle?

z/OS 的 DB2 是否具有与 Oracle 中的 READ ONLY 类似的隔离级别? 我需要对 DB2 实施几个大选择,还需要检索在查询开始时按时提交的一致数据,因此我需要类似 'snapshot isolation level' 的东西。据我所知,在 Oracle 中它可以通过 READ ONLY 隔离级别实现,但是对于 z/OS?

的 DB2 呢?

DB2 z/OS 中有一个 FOR READ ONLY 子句。您将其添加在查询的末尾。

For tables in which updates and deletes are allowed, specifying FOR READ ONLY can possibly improve the performance of FETCH operations as DB2® can do blocking and avoid exclusive locks. For example, in programs that contain dynamic SQL statements without the FOR READ ONLY or ORDER BY clause, DB2 might open cursors as if the UPDATE clause was specified.

这是包含更多信息的 Info Center article


如果您真的要寻找 "Serializable" 的 DB2 版本,那么您正在寻找 Repeatable Read

DB2 for z/OS 没有 "read only" 隔离级别(Oracle 也没有,因为 "read only" 是事务状态,而不是隔离级别)。

如果您使用 currently committed concurrent access resolution option,您可以避免查询的锁等待,但是请注意,它本身并没有实现 "snapshot isolation" -- 使用此选项的查询将看到最新提交的更改,即使这些更改是在查询开始之后提交的。