Oracle equivalent of SQL Server Snapshot isolation

Ven*_*Vig 6 sql oracle snapshot-isolation isolation-level read-committed-snapshot

In Microsoft SQL Server, I use the READ_COMMITTED_SNAPSHOT ISOLATION

ALTER DATABASE MyDatabase
SET ALLOW_SNAPSHOT_ISOLATION ON

ALTER DATABASE MyDatabase
SET READ_COMMITTED_SNAPSHOT ON
Run Code Online (Sandbox Code Playgroud)

In Session 1,update the Principal from 4000 to 5000

BEGIN TRAN
Update MyTable Set Principal=5000 Where InvestorId=10 
Run Code Online (Sandbox Code Playgroud)

Now in Session 2, I say

Select Principal from MyTable where InvestorId=10
Run Code Online (Sandbox Code Playgroud)

I get 4000, since the Session 1 Transaction is not committed.

If I do not use the READ_COMMITTED_SNAPSHOT isolation mode, and use

  1. READ COMMITTED ISOLATION Mode then my Session 2 will keep waiting
  2. If I use READ_UNCOMMITTED ISOLATION Mode then my session 2 will give 5000 (equivalent to using a nolock on the select statement)

In Oracle, if I perform the equivalent set of commands, by default it behaves as if the READ_COMMITTED_SNAPSHOT isolation mode is set.

I read in microsoft articles that SNAPSHOT isolation mode writes to the tempdb before updates are done.

-How does Oracle achieve this by default ?

-Is it also writing to the disk ? does it cause i/o problems ?

- Oracle 中的默认锁定级别与 SQL Server 不同吗?

提前感谢您的帮助和时间。

小智 4

在Oracle中,READ_COMMITTED隔离级别是默认模式,即数据只有在COMMIT之后才会写入数据文件(磁盘)并可供其他会话选择。为此,它使用 UNDO 段。在执行选择时,它不会导致任何 I/O 问题 Oracle 默认情况下使用行级锁定。

您可以查看Oracle数据库概念的第9章和第10章以了解更多详细信息