Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

What is the default transaction isolation level in PostgreSQL, MySQL InnoDB, Oracle and SQL Server, and what does Spring's Isolation.DEFAULT mean?

Try it yourself

Isolation levels: what a second read sees

Step through two transactions and see exactly when read committed and repeatable read give different answers.

Read this example as text

T1 at read committed

  1. T1 begins. Transaction T1 starts with isolation level READ COMMITTED. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under read committed each statement looks afresh at what is committed when the statement starts.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 reads 150. The same query, inside one transaction, returned 100 and then 150. This is a non-repeatable read, and read committed allows it.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100, 100, then 150: a non-repeatable read.

T1 at repeatable read

  1. T1 begins. Transaction T1 starts with isolation level REPEATABLE READ. The row holds balance 100.
  2. T1 reads the balance. T1 reads 100. Under repeatable read this first read fixes T1's snapshot: T1 will keep seeing the data as it was committed at this moment.
  3. T2 changes the row. A second transaction, T2, sets the balance to 150 but has not committed. The database keeps both versions: 100 is still the committed one.
  4. T1 reads again, before T2 commits. T1 reads 100 again. Neither level shows another transaction's uncommitted change, so there is no dirty read. T1 does not wait for T2 either.
  5. T2 commits. T2 commits. The committed balance is now 150.
  6. T1 reads a third time. T1 still reads 100. Its snapshot was fixed at its first read, so T2's commit is invisible to it. The read is repeatable.
  7. T1 commits. T1 ends. A transaction that starts now reads 150 at either level.

T1 read 100 three times: its reads were repeatable.

What this example leaves out
  • Modelled on PostgreSQL and MySQL InnoDB, where a plain SELECT reads a snapshot and never waits for a writer.
  • SQL Server's default read committed uses locks instead: there, T1's second read would wait for T2 to finish.
  • Only reads are compared. What happens when T1 also writes the row (a lost update, or an error in PostgreSQL) is not modelled.

PostgreSQL, Oracle and SQL Server default to READ COMMITTED, and MySQL InnoDB defaults to REPEATABLE READ; SQL Server implements READ COMMITTED with locks unless the READ_COMMITTED_SNAPSHOT option is on, which it is by default in Azure SQL Database. Spring's Isolation.DEFAULT means Spring does not set any level, so whatever the driver or database uses applies, and we can override it per transaction with @Transactional(isolation = ...).

Why this question is asked

Most Spring code never mentions isolation, which means it runs at the database's default, and that default is not the same everywhere. Worse, the same name can mean different behaviour in different products. Interviewers ask this to check that we know what our code actually runs at and what Spring does about it. In this answer, we will list the defaults, see why equal names do not mean equal behaviour, explain Isolation.DEFAULT and per-transaction overrides, and show how to check the level in each database.

1A Quick Recap of Isolation Levels

An isolation level is a promise about how much concurrent transactions can affect each other. The SQL standard defines four, from weakest to strongest: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE, in terms of which anomalies each must prevent, such as dirty reads (seeing uncommitted data) or non-repeatable reads (reading the same row twice and getting different values). The standard says what must not happen, not how to implement it, which is why products differ.

2The Defaults in the Four Databases

PostgreSQL defaults to READ COMMITTED, implemented with MVCC: each statement sees a snapshot of committed data. Oracle also defaults to READ COMMITTED with statement-level snapshots from its undo data. SQL Server defaults to READ COMMITTED too, but traditionally implements it with shared locks, so readers wait for writers; if the database option READ_COMMITTED_SNAPSHOT is ON, the same level uses row versions instead and readers stop blocking. That option is off by default in an on-premises SQL Server and on by default in Azure SQL Database. MySQL with InnoDB is the odd one out: its default is REPEATABLE READ.

Default isolation by database
DatabaseDefault levelHow it is implemented
PostgreSQLREAD COMMITTEDMVCC, new snapshot per statement
OracleREAD COMMITTEDMVCC from undo, snapshot per statement
SQL ServerREAD COMMITTEDlocks, or row versions if READ_COMMITTED_SNAPSHOT
Azure SQL DatabaseREAD COMMITTEDrow versions: READ_COMMITTED_SNAPSHOT on
MySQL InnoDBREPEATABLE READsnapshot for plain reads, latest row for writes

3The Same Name, Different Behaviour

PostgreSQL's REPEATABLE READ is snapshot isolation: one snapshot for the whole transaction, and an UPDATE of a row changed after that snapshot fails with SQLSTATE 40001. InnoDB's REPEATABLE READ gives plain SELECTs a consistent snapshot too, but UPDATE, DELETE and locking reads such as SELECT ... FOR UPDATE work on the latest committed data and do not fail.

SQL
-- MySQL InnoDB, REPEATABLE READ
START TRANSACTION;
SELECT qty FROM stock WHERE id = 7; -- 10, snapshot
-- another session commits qty = 4
SELECT qty FROM stock WHERE id = 7; -- 10, same snapshot
SELECT qty FROM stock WHERE id = 7 FOR UPDATE; -- 4, the latest committed row
UPDATE stock SET qty = qty - 1 WHERE id = 7; -- succeeds, qty = 3
-- PostgreSQL, REPEATABLE READ, same steps without FOR UPDATE
UPDATE stock SET qty = qty - 1 WHERE id = 7;
-- ERROR: could not serialize access due to concurrent update

So code that is safe at REPEATABLE READ on one database is not automatically safe on another. When we say which level a service runs at, we also need to say which product.

4What Isolation.DEFAULT Means in Spring

Isolation.DEFAULT is the default value of the isolation attribute of @Transactional. It does not mean READ COMMITTED or any other level. It means Spring does not touch the isolation of the connection, so the transaction runs at whatever the connection already has: the pool's configured level if there is one (HikariCP's transactionIsolation property), otherwise the driver's and database's default, which in PostgreSQL can itself be changed with default_transaction_isolation.

Java
@Transactional // Isolation.DEFAULT: Spring sets nothing
public void normal() { ... } // PostgreSQL: READ COMMITTED
@Transactional(isolation = Isolation.REPEATABLE_READ)
public Report monthly() { ... }
// Spring calls connection.setTransactionIsolation(TRANSACTION_REPEATABLE_READ) before the work;
// the driver sends the equivalent of SET TRANSACTION ISOLATION LEVEL REPEATABLE READ

With DataSourceTransactionManager, Spring remembers the connection's previous level and restores it when the transaction ends, before the connection goes back to the pool; pools such as HikariCP also reset changed isolation on return. So one transaction's level does not leak into the next borrower. With JPA, the dialect must support custom isolation; Hibernate's does through Spring's HibernateJpaDialect. An isolation level on a method that joins an existing transaction is ignored, because the level is fixed when the outer transaction starts.

5Changing It Deliberately

Because the default depends on the product and its configuration, a service whose correctness depends on isolation should state it explicitly, either per method or for the whole service via the pool or the database role, and its design document should say why. Isolation.DEFAULT is fine when the code does not rely on anything beyond READ COMMITTED; it is a trap when someone assumed REPEATABLE READ because they once used MySQL.

6Follow-up questions

How do you check the current level in each database?

In PostgreSQL, SHOW transaction_isolation; returns the level of the current transaction, and SHOW default_transaction_isolation; the default. In MySQL, SELECT @@transaction_isolation; for the session and SELECT @@GLOBAL.transaction_isolation; for the server. In SQL Server, DBCC USEROPTIONS shows the session's isolation level, and SELECT is_read_committed_snapshot_on FROM sys.databases WHERE name = DB_NAME(); shows whether READ COMMITTED uses row versions. Oracle has no simple session variable; the default is READ COMMITTED unless the session ran ALTER SESSION SET ISOLATION_LEVEL, and an active transaction's level can be derived from v$transaction (check your version). From Java, connection.getTransactionIsolation() works everywhere.

Does PostgreSQL support READ UNCOMMITTED?

It accepts the name but behaves as READ COMMITTED, so dirty reads never happen. Oracle does not offer READ UNCOMMITTED at all.

Does Spring Boot set an isolation level by default?

No. Unless we configure the pool's transaction isolation or use the isolation attribute, the database default applies.

7Conclusion

In this answer, we saw that PostgreSQL, Oracle and SQL Server default to READ COMMITTED, with SQL Server using locks unless READ_COMMITTED_SNAPSHOT is on as it is in Azure SQL Database, and that MySQL InnoDB defaults to REPEATABLE READ, which behaves differently from PostgreSQL's level of the same name. Spring's Isolation.DEFAULT means Spring sets nothing and the driver or database default applies; a specific level per transaction is applied with setTransactionIsolation and restored when the connection returns.

What to say in the interviewAbout 80 seconds aloud

Open with

PostgreSQL defaults to READ COMMITTED, Oracle to READ COMMITTED, SQL Server to READ COMMITTED, and MySQL with InnoDB to REPEATABLE READ. In SQL Server, READ COMMITTED is implemented with shared locks unless the READ_COMMITTED_SNAPSHOT option is on, and in Azure SQL Database it's on by default, so readers use row versions instead of blocking.

Then, if they want more

I'd also point out that the same name doesn't mean the same behaviour. PostgreSQL's REPEATABLE READ is snapshot isolation, so updating a row that changed after your snapshot fails with a serialization error. InnoDB's REPEATABLE READ snapshots plain selects, but updates and locking reads see the latest committed row and don't fail.

In Spring, Isolation.DEFAULT is the default value on @Transactional, and it means Spring doesn't set anything, so the connection keeps whatever the pool, driver or database default is.

If I set a level, like @Transactional with isolation REPEATABLE_READ, Spring calls setTransactionIsolation on the connection at the start, which the driver turns into the equivalent of SET TRANSACTION, and it restores the previous level at the end; the pool also resets it when the connection is returned.

The level only applies when the transaction starts, so on a method that joins an existing transaction it's ignored.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the default transaction isolation level in PostgreSQL, MySQL InnoDB, Oracle and...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/8dc968e720/