Chapter 07 · DML, Transactions, Read Consistency, Undo, Locks, and Concurrency

Oracle Read Consistency, SCNs, Undo, Statement-Level Snapshots, and Consistent Gets

Observe Oracle SCN-based read consistency, undo reconstruction, statement snapshots, and consistent gets without confusing logical reads with physical I/O.

Advanced115–135 minutesTwo-session SCN/read-consistency labREAD COMMITTED statement snapshotsFree · optional V$ observer privilegesLast reviewed: August 2026

Learning outcomes

A technician is editing a work order while a dispatcher runs a report. Oracle does not normally make the report wait for the writer, nor does it expose the writer's uncommitted value. Instead, the query receives a coherent version of the data as of a System Change Number (SCN), reconstructing older block images from undo when needed.

01

Explain SCNs as Oracle ordering/version points used for consistent reads.

02

Distinguish default statement-level READ COMMITTED snapshots from transaction-level read-only/serializable snapshots.

03

Explain how undo creates consistent-read block versions while writers continue.

04

Distinguish consistent gets from physical reads.

05

Use a two-session timeline to verify visibility before and after COMMIT.

Lab, release, and licensing baseline

Mandatory exercises target the disposable ServiceHub schema in Oracle AI Database Free 26ai. Current documentation was re-checked against RU 23.26.3, SQL Developer 26.2, and SQLcl 26.2. Oracle AI Database Free is limited to 2 foreground CPUs, 2 GB combined SGA/PGA memory, and 12 GB user data and receives no Oracle patches or Support SRs. No paid option, management pack, RAC, Data Guard, Exadata, or cloud service is required. Dynamic performance views shown as observer evidence can require catalog privileges and are clearly separated from application-owner work.

1. SCN: a database ordering point, not a wall-clock timestamp

Oracle assigns System Change Numbers to order database changes. When a SELECT begins execution under the default READ COMMITTED isolation level, it reads data consistent with the statement's snapshot SCN. Rows changed after that point are not allowed to leak into the result midway through the statement.

sql · optional SCN evidence when EXECUTE on DBMS_FLASHBACK is available
SELECT DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER AS current_scnFROM dual;

The returned SCN is useful evidence of database progression, but it is not a business timestamp and should not be treated as a portable sequence across unrelated databases.

2. Undo does more than ROLLBACK

When a query needs an older committed version of a block, Oracle can copy a current buffer and apply undo records to reconstruct a consistent read (CR) clone. This is the mechanism behind readers seeing a coherent snapshot while another transaction changes the same table. Undo therefore serves rollback, recovery, read consistency, and flashback-related use cases.

Mechanism boundary

Undo reconstruction does not mean Oracle reads a second historical table. The database derives an older logical image of changed blocks from undo records. If the required undo has already been overwritten, a long-running reader can fail with ORA-01555; Lesson 5 diagnoses that separately.

3. Two-session timeline: readers see committed versions

Open two SQLcl/SQL*Plus/SQL Developer sessions as the same lab user. The first query in Session A sees the committed starting value. Session B then changes the row but deliberately does not commit.

sql · one-time setup
DROP TABLE sh07_consistency IF EXISTS PURGE;CREATE TABLE sh07_consistency (    work_order_id NUMBER PRIMARY KEY,    amount        NUMBER(10,2) NOT NULL);INSERT INTO sh07_consistency VALUES (701,500);COMMIT;
sql · Session A — baseline statement
SELECT amount FROM sh07_consistency WHERE work_order_id = 701;-- Expected: 500
sql · Session B — uncommitted change
UPDATE sh07_consistencySET amount = 900WHERE work_order_id = 701;-- Do not COMMIT yet.
sql · Session A — new statement while B is uncommitted
SELECT amount FROM sh07_consistency WHERE work_order_id = 701;-- Expected: still 500. Oracle does not expose B's uncommitted value.

Now commit Session B and run another query in Session A.

sql · Session B then Session A
-- Session BCOMMIT;-- Session A: this is a new READ COMMITTED statement with a new snapshot.SELECT amount FROM sh07_consistency WHERE work_order_id = 701;-- Expected: 900.

This demonstrates two distinct facts: a reader did not dirty-read an uncommitted value, and a later statement under READ COMMITTED can see a newly committed value. A single long-running SELECT keeps one statement snapshot even while commits happen elsewhere.

4. Read-only transaction: contrast statement and transaction snapshots

If a reporting unit requires several queries to see the same committed point, a read-only transaction can provide transaction-level consistency. This is a different requirement from the default per-statement snapshot.

sql · Session A — stable reporting transaction
COMMIT;SET TRANSACTION READ ONLY;SELECT amount FROM sh07_consistency WHERE work_order_id = 701;-- In Session B, update the row and COMMIT.SELECT amount FROM sh07_consistency WHERE work_order_id = 701;-- This read-only transaction continues to see its transaction snapshot.COMMIT;

Do not switch to stronger isolation just because “consistency sounds safer.” Longer snapshots increase the age of undo versions a report may need and can change concurrency/error behavior.

5. Consistent gets are logical reads, not disk reads

Oracle performance statistics use consistent gets for logical buffer accesses in consistent mode. They can include blocks already in the buffer cache and blocks reconstructed using undo. They are not synonymous with physical reads from storage.

sql · optional DBA/observer view for the current session
SELECT s.sid,       io.consistent_gets,       io.physical_reads,       io.block_changesFROM v$session sJOIN v$sess_io io ON io.sid = s.sidWHERE s.audsid = SYS_CONTEXT('USERENV','SESSIONID');

If consistent_gets rises while physical_reads does not, the query still performed logical buffer work. Conversely, one physical I/O can feed later logical reads. Diagnose these metrics separately.

6. Deliberately wrong mental model: readers must lock rows to stay consistent

Applying a SQL Server-style blocking-reader intuition to ordinary Oracle queries leads to unnecessary SELECT FOR UPDATE, serialized workers, and avoidable contention. Plain Oracle queries normally do not take row locks merely to protect their read view; SCN plus undo provide consistency.

Use SELECT FOR UPDATE only when the application intends to lock selected rows for a subsequent write, not to “make SELECT consistent.” Lesson 4 shows the lock consequences.

7. Cleanup and production judgment

sql · cleanup after both sessions are finished
ROLLBACK;DROP TABLE sh07_consistency PURGE;

Monitor long query duration together with undo retention and workload rather than chasing a universal undo setting. On default READ COMMITTED, understand that two successive statements may legitimately see different committed states. When a business process needs cross-statement consistency, choose read-only/serializable behavior consciously and test the resulting concurrency. No paid diagnostic pack is needed for the basic dynamic views shown here, although access privileges are required.

8. Summary and next step

Oracle snapshots are version-based: SCNs define the required point, undo can reconstruct older block images, and consistent gets measure logical consistent-read work. This architecture lets readers and writers proceed concurrently in many cases. Lesson 4 turns to the cases where the application intentionally locks rows and must diagnose TX/TM enqueues.

Check your understanding

  1. What does the statement snapshot SCN control?
  2. Why can Session A read 500 while Session B has changed the row to 900 but not committed?
  3. Does a consistent get mean Oracle read a block from disk?
  4. Why can two READ COMMITTED SELECTs in one session see different values?
  5. What problem does a read-only transaction solve?
Review the answers

It defines the committed database version the statement must see consistently.

Oracle uses read consistency and undo to present the last committed version instead of exposing uncommitted data.

No. It is a logical read in consistent mode; physical I/O is a different statistic.

Each statement gets its own snapshot, so a later statement can see commits that happened after the earlier statement began.

It lets multiple queries in the transaction share a stable transaction-level view when that is the required reporting contract.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.