6

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

In Session 1,update the Principal from 4000 to 5000

BEGIN TRAN
Update MyTable Set Principal=5000 Where InvestorId=10 

Now in Session 2, I say

Select Principal from MyTable where InvestorId=10

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 ?

-Is the default locking level in Oracle different from SQL server ?

Thanks in advance for your help and time.

VenVig
  • 645
  • 1
  • 10
  • 14

2 Answers2

4

In Oracle, the READ_COMMITTED Isolation level is the default mode, i.e. data is written to the datafile (disk) and available for select by other sessions only after COMMIT. It uses UNDO segment for this. It does not cause any I/O problem while doing a select Oracle uses Row Level Locking by default.

You can have a look at Chapters 9 and 10 of Oracle DataBase Concepts for more details

Jay Sullivan
  • 17,332
  • 11
  • 62
  • 86
vishad
  • 1,134
  • 7
  • 11
  • https://docs.oracle.com/cd/E17276_01/html/gsg_xml_txn/cxx/isolation.html#snapshot_isolation – suresh Feb 21 '17 at 04:45
  • Notice that mssql's READ COMMITTED SNAPSHOT and SNAPSHOT aren't exactly the same. So while this answers the OP's question, there is more to say about it: https://dba.stackexchange.com/questions/54680/sql-servers-read-committed-snapshot-vs-snapshot – Johan Boulé Jan 07 '21 at 11:18
1

In Oracle, its a non blocking queries by default.. similar to SQL snapshot isolation mode. The locking behaviour still in place but doesn't affect reads which only query committed data before transaction started on affected rows thus avoiding dirty reads. see chapter 9 - Non blocking queries.

  • Please try to provide more information to improve the answers, such as examples - preferably use the same examples used in question. – Jithin Scaria Jun 28 '18 at 08:56
  • Notice that mssql's READ COMMITTED SNAPSHOT and SNAPSHOT aren't exactly the same. So while this answers the OP's question, there is more to say about it: https://dba.stackexchange.com/questions/54680/sql-servers-read-committed-snapshot-vs-snapshot – Johan Boulé Jan 07 '21 at 11:18