Transaction

  • A Unit of work done against the DB in a logical sequence, nothing but Transaction in DBMS.
OR
  • Transaction is a set of operations that are all logically related to each other.


Transaction in DBMS is nothing but a logical unit of work that contains one or more SQL statements. The result of all these statements in a transaction either gets completed successfully or if at any point any failure happens it gets rollbacked.

For Examples

  1. Adding a new member to the database(DB) of a team is a transaction.
  2. Money transfer from one bank to another is a transaction.


Transaction States in DBMS

  • A transaction goes through many different states or layers throughout its life cycle, these states are nothing but transaction states.

Transaction in DBMS and States of Transaction

States of Transaction

  1. Active state
  2. Partially committed state
  3. Committed state
  4. Failed state
  5. Aborted state
  6. Terminated state

Active State

  • The first state(layer) of the transaction life cycle. 
  • Transaction in an active state as long as its instructions(SQL statement) are getting executed.
  • Changes made in an active state are now stored in the buffer in the main memory(RAM).

Partially Committed State

  • After executing the last instruction of transaction enter into a partially committed state.
  • In this state, transactions are considered partially committed because all the changes made by the transaction are still stored in the buffer in the main memory.

Committed State

  • Whatever changes made by a transaction have been successfully stored in the database. then enters into a committed state.

Failed State

  • Transaction getting executed in the active state or partially committed state and some failure occurs due to which it becomes impossible to continue the execution, it enters into a failed state.

Aborted State

  • Transaction failed then enters into a failed state, all the changes made by it have to be undone or rolled back.
  • after the rollback transaction enters into an aborted state.

Terminated State

  • Last state of the transaction.
  • Committed state or aborted state, after that transaction, enter into the terminated state.