Write Skew anomaly in Oracle and PostgreSQL does not rollback transaction

后端 未结 4 2005
情话喂你
情话喂你 2021-02-01 10:42

I noticed the following occurrence in both Oracle and PostgreSQL.

Considering we have the following database schema:

create table post (
    id int8 not          


        
4条回答
  •  执笔经年
    2021-02-01 11:07

    What you observe is not a phantom read. That would be if a new row would show up when the query is issued the second time (phantoms appear unexpectedly).

    You are protected from phantom reads in both Oracle and PostgreSQL with SERIALIZABLE isolation.

    The difference between Oracle and PostgreSQL is that SERIALIZABLE isolation level in Oracle only offers snapshot isolation (which is good enough to keep phantoms from appearing), while in PostgreSQL it will guarantee true serializability (i.e., there always exists a serialization of the SQL statements that leads to the same results). If you want to get the same thing in Oracle and PostgreSQL, use REPEATABLE READ isolation in PostgreSQL.

提交回复
热议问题