Table of Contents
What happens during a commit
How rollback works with undo
Redo vs Undo – Key differences
Practical implications and tuning considerations
Home Database Oracle How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms?

How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms?

Jul 08, 2025 am 12:16 AM
oracle transaction management

Oracle ensures transaction durability and consistency using redo for commits and undo for rollbacks. During a commit, Oracle generates a commit record in the redo log buffer, marks changes as permanent in redo logs, and updates the SCN to reflect the current database state. For rollbacks, Oracle uses undo data to revert changes by reconstructing original values and maintaining read consistency. Redo records changes for recovery, stored in online redo logs, while undo stores how to reverse changes for rollback and consistency, kept in undo tablespaces. Key practical considerations include: 1) frequent commits increase redo but reduce undo usage; 2) large transactions may trigger "snapshot too old" errors if undo retention is insufficient; 3) monitor redo via V$SYSSTAT or trace files; 4) ensure adequate undo tablespace size and retention for long queries; and 5) check wait events like log file sync or enq: TX – contention when troubleshooting performance issues.

Oracle handles transaction commits and rollbacks using two core mechanisms: redo and undo. These work together to ensure data consistency, durability, and the ability to recover from failures.


What happens during a commit

When you issue a COMMIT, Oracle doesn’t immediately write all changes to the data files. Instead, it does a few key things:

  • It generates a commit record in the redo log buffer.
  • All the changes made by the transaction up to that point are marked as permanent in the redo logs.
  • The System Change Number (SCN) is updated to reflect the current point in time of the database.

So even if the actual data blocks haven’t been written to disk yet, the fact that the transaction committed is recorded in the redo log. That’s why Oracle can guarantee durability — once a commit returns successfully, the change is safe, even in case of a crash.


How rollback works with undo

If a transaction is rolled back (either explicitly or due to an error), Oracle uses undo data to revert the changes.

Each change made by a transaction is first logged in the undo tablespace before the actual data is modified. This allows Oracle to:

  • Reconstruct the original values of changed data.
  • Maintain read consistency for other sessions that might be querying the same data concurrently.

For example, if Session A updates a row and Session B queries it before the commit, Session B sees the original version of the row using the undo data.

Rollback essentially plays back this undo information in reverse, restoring the database to its state before the transaction began.


Redo vs Undo – Key differences

It's easy to mix up redo and undo, but here's how they differ in function:

  • Redo:

    • Records what changes were made to the database.
    • Used for recovery — instance recovery, media recovery, etc.
    • Stored in online redo log files.
    • Every change goes through the redo log buffer before being flushed to disk.
  • Undo:

    • Records how to undo a change.
    • Used for rollbacks and maintaining read consistency.
    • Stored in undo tablespaces.
    • Also used by Oracle for flashback features and consistent reads.

In short:

Redo is about recording changes for recovery; undo is about preserving old values for rollback and consistency.


Practical implications and tuning considerations

Understanding these mechanisms helps when dealing with performance or recovery issues.

Here are a few practical points:

  • Frequent commits reduce the amount of undo needed but increase redo generation. So, in bulk operations, batch your commits wisely.
  • Large transactions may cause "snapshot too old" errors if undo retention isn't sufficient.
  • You can monitor redo generation via views like V$SYSSTAT (redo size) or trace files.
  • For long-running reports or queries, make sure your undo tablespace is large enough and configured with appropriate retention.

If you're troubleshooting performance issues related to redo or undo, checking wait events like log file sync (for redo) or enq: TX – contention (for undo) can help pinpoint bottlenecks.


That’s how Oracle ensures reliable transaction handling under the hood. Not something you see every day, but good to understand when tuning or debugging database behavior.

The above is the detailed content of How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

ArtGPT

ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT

Stock Market GPT

AI powered investment research for smarter decisions

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Using Oracle Database Integration with Hadoop in Big Data Environment Using Oracle Database Integration with Hadoop in Big Data Environment Jun 04, 2025 pm 10:24 PM

The main reason for integrating Oracle databases with Hadoop is to leverage Oracle's powerful data management and transaction processing capabilities, as well as Hadoop's large-scale data storage and analysis capabilities. The integration methods include: 1. Export data from OracleBigDataConnector to Hadoop; 2. Use ApacheSqoop for data transmission; 3. Read Hadoop data directly through Oracle's external table function; 4. Use OracleGoldenGate to achieve data synchronization.

How to do oracle without taking a certain field value How to do oracle without taking a certain field value Jun 04, 2025 pm 10:21 PM

In Oracle database, if you want to not return the value of a certain field when querying, you can use the following three methods: Only list the required fields in the SELECT statement and do not select the unwanted fields. Create views to simplify queries, but pay attention to the complexity and maintenance costs of the views. Excluding unwanted columns using subqueries or JOINs is suitable for dynamic exclusion of columns, but may affect query performance. Each method has its applicable scenarios and potential disadvantages, and the most suitable method needs to be selected based on specific needs and performance considerations.

What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon What is Impossible Cloud Network (ICNT)? How? A comprehensive introduction to the ICN project that Binance will launch soon Jul 07, 2025 pm 07:06 PM

Contents 1. What is ICN? 2. ICNT latest updates 3. Comparison and economic model between ICN and other DePIN projects and economic models 4. Conclusion of the next stage of the DePIN track At the end of May, ICN (ImpossibleCloudNetwork) @ICN_Protocol announced that it had received strategic investment in NGPCapital with a valuation of US$470 million. Many people's first reaction was: "Has Xiaomi invested in Web3?" Although this was not Lei Jun's direct move, the one who had bet on Xiaomi, Helium, and WorkFusion

What are the differences between physical and logical database structures in Oracle? What are the differences between physical and logical database structures in Oracle? Jun 10, 2025 am 12:01 AM

The logical structure of Oracle database focuses on how data is organized by users and developers, including tables, views, patterns and table spaces; the physical structure involves the actual storage of data on disk, including data files, redo logs, control files, etc. 1. The logical structure includes tables, views, indexes, patterns and table spaces, which determine how users access data; 2. The physical structure consists of data files, redo logs, control files and archive logs, which are responsible for the persistence and recovery of data; 3. The table space is a key bridge connecting logic and physics, and its capacity is limited by the underlying data files; 4. Different roles have different levels of attention, developers focus on logic optimization, and DBA pays more attention to physical management; 5. Understanding the differences between the two can help efficiently troubleshoot problems, optimize performance and reasonable management

How to create a new username and password in oracle How to create a new username and password in oracle Jun 04, 2025 pm 10:18 PM

Create a new username and password in the Oracle database using the CREATEUSER statement. 1. Create a user and set password: CREATEUSERnew_userIDENTIFIEDBYpassword123; 2. Assign permissions: GRANTCONNECT, RESOURCETOnew_user; 3. Set space quota: ALTERUSERnew_userQUOTA100MONusers; 4. Select the appropriate table space to optimize performance; 5. Set password expiration policy: ALTERUSERnew_userPASSWORDEXPIRE to enhance security.

What is the purpose of temporary tablespaces in Oracle? What is the purpose of temporary tablespaces in Oracle? Jun 27, 2025 am 12:58 AM

TemporarytablespacesinOracleareusedtostoretemporarydataduringSQLoperationslikesorting,hashing,andglobaltemporarytables.1)SortingoperationssuchasORDERBY,GROUPBY,orDISTINCTmayrequirediskspaceifmemoryisinsufficient.2)Hashjoinsonlargedatasetsusetemporary

How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms? How does Oracle manage transaction commits and rollbacks using redo and undo mechanisms? Jul 08, 2025 am 12:16 AM

Oracleensurestransactiondurabilityandconsistencyusingredoforcommitsandundoforrollbacks.Duringacommit,Oraclegeneratesacommitrecordintheredologbuffer,markschangesaspermanentinredologs,andupdatestheSCNtoreflectthecurrentdatabasestate.Forrollbacks,Oracle

What is Ethereum cross-chain bridge? How to achieve asset transfer? What is Ethereum cross-chain bridge? How to achieve asset transfer? Jul 02, 2025 pm 10:57 PM

Blockchain technology has spawned many independent networks, such as Ethereum, Binance Smart Chain, Polygon, etc. Each network has its own unique design and protocol. However, this independence also presents the challenge of difficult assets and information flowing freely between different chains. For example, ERC-20 tokens on Ethereum cannot be used directly on the Polygon network. In order to solve this isolation problem, cross-chain bridges emerged and became the key infrastructure to connect different blockchain networks.

See all articles