hannibal 论述“oracle读出的数据当前可能是不正确的”的论据是“oracle可以利用SCN找到最早的数据(注意这不是当前的数据)”。这个论据是错误的,我的依据如下:
“Whenever a transaction is committed, LGWR writes the transaction redo records from the redo log buffer of the SGA to a redo log file, and assigns a system change number (SCN) to identify the redo records for each committed transaction.”(摘自Oracle联机文档 http://download-west.oracle.com/ ... 4231/onlineredo.htm)。无论多么小的事务,每次提交commit产生一个新SCN号。
“When the Oracle server begins executing a SELECT statement, it determines the current system change number (SCN) and ensures that any changes not committed before this SCN are not processed by the statement.”(摘自Oracle DBA教材) 。注意是“current”SCN ,不是hannibal 认为的“最早的”SCN。
假设多个查询发起时SCN不一样(不同时开始),而且多个查询发起之间出现了相关数据提交,即便多个查询同时结束,查询的结果也会不同,即,查询结果有多个版本。每个查询都查到自己发起那一时刻的一致性数据(每个查询发起时的数据快照),结果中没有未提交的数据,即,没有不一致数据。这就是Oracle“多版本读一致性”。所以,我的结论是Oracle读的是正确的数据。