Transaction States in DBMS
Last Updated :
16 Jun, 2025
A transaction in DBMS is a sequence of operations performed as a single logical unit of work (e.g., transferring money between accounts). All operations in a transaction are executed together to ensure consistency. Transaction state represents the current stage of a transaction, indicating its progress and whether it completes successfully or fails.
- A transaction goes through several states during its lifetime.
- A transaction log is used to keep a record of all the steps taken during the transaction.
- A transaction involves two main operations, Read Operation and Write Operation.
- Read Operation: Reads data from the database, stores it temporarily in memory (buffer), and uses it as needed.
- Write Operation: Updates the database with the changed data using the buffer.
Note: From the start of executing instructions to the end, Read and Write operations are treated as a single transaction. This ensures the database remains consistent and reliable throughout the process.
Different Types of Transaction States in DBMS
These are the different types of Transaction States:
- Active State
- Partially Committed State
- Failed State
- Aborted State
- Committed State
- Terminated State
Transaction States1. Active State
- It is the first stage of any transaction when it has begun to execute. The execution of the transaction takes place in this state.
- Operations such as insertion, deletion, or updation are performed during this state.
- During this state, the data records are under manipulation and they are not saved to the database, rather they remain somewhere in a buffer in the main memory.
2. Partially Committed
- The transaction has finished its final operation, but the changes are still not saved to the database.
- After completing all read and write operations, the modifications are initially stored in main memory or a local buffer. If the changes are made permanent in the database then the state will change to "committed state" and in case of failure it will go to the "failed state".
3. Committed
This state of transaction is achieved when all the transaction-related operations have been executed successfully along with the Commit operation, i.e. data is saved into the database after the required manipulations in this state. This marks the successful completion of a transaction.
4. Failed State
If any of the transaction-related operations cause an error during the active or partially committed state, further execution of the transaction is stopped and it is brought into a failed state. Here, the database recovery system makes sure that the database is in a consistent state.
5. Aborted State
If a transaction reaches the failed state due to a failed check, the database recovery system will attempt to restore it to a consistent state. If recovery is not possible, the transaction is either rolled back or cancelled to ensure the database remains consistent.
In the aborted state, the DBMS recovery system performs one of two actions:
- Kill the transaction: The system terminates the transaction to prevent it from affecting other operations.
- Restart the transaction: After making necessary adjustments, the system reverts the transaction to an active state and attempts to continue its execution.
6. Terminated State
It refers to the final state of a transaction, indicating that it has completed its execution. Once a transaction reaches this state, it has either been successfully committed or aborted. In this state, no further actions are required from the transaction, as the database is now stable.
Example of Transaction States
Imagine a bank transaction where a user wants to transfer $500 from Account A to Account B. The system should handle the following transaction states:
1. Active State:
- The transaction begins. It reads the balance of Account A and checks if it has enough funds.
- Example: Read balance of Account A = $1000.
2. Partially Committed State:
- The transaction performs all its operations but hasn’t yet saved (committed) the changes to the database.
- Example: Deduct $500 from Account A's balance ($1000 - $500 = $500) and temporarily update Account B's balance (add $500).
3. Committed State:
- The transaction successfully completes, and the changes are saved permanently in the database.
- Example: Account A’s new balance = $500; Account B’s new balance = $1500. Changes are written to the database.
4. Failed State:
- If something goes wrong during the transaction (e.g., power failure, system crash), the transaction moves to this state.
- Example: System crashes after deducting $500 from Account A but before adding it to Account B.
5. Aborted State:
- The failed transaction is rolled back, and the database is restored to its original state.
- Example: Account A's balance is restored to $1000, and no changes are made to Account B.
These states ensure that either the transaction completes successfully (committed) or the database is restored to its original state (aborted), maintaining consistency and preventing errors.
Similar Reads
Transaction in DBMS In a Database Management System (DBMS), a transaction is a sequence of operations performed as a single logical unit of work. These operations may involve reading, writing, updating, or deleting data in the database. A transaction is considered complete only if all its operations are successfully ex
10 min read
Transaction Isolation Levels in DBMS The levels of transaction isolation in DBMS determine how the concurrently running transactions behave and, therefore, ensure data consistency with performance being even. There are four basic levels- Read Uncommitted, Read Committed, Repeatable Read, and Serializable that provide different degrees
6 min read
Transaction Control in DBMS The transaction is a single logical unit that accesses and modifies the contents of the database. Transactions access data using read and write operations. Transaction is a single operation of processing that can have many operations. Transaction is needed when more than one user wants to access sam
5 min read
Transactions in NoSQL A NoSQL originally referring to non SQL or nonrelational is a database that provides a mechanism for storage and retrieval of data. In this article, we will see NoSQL transactions. There are some features of NoSQL: It has the feature of Horizontal Scaling.The main advantage of using NoSQL is that it
4 min read
Transaction Management Transactions are a set of operations used to perform a logical set of work. A transaction usually means that the data in the database has changed. One of the major uses of DBMS is to protect the user data from system failures. It is done by ensuring that all the data is restored to a consistent stat
9 min read