Understanding Transaction Processing

This chapter provides an overview of transaction processing and discusses how to work with transaction processing.

A transaction is a logical unit of work (comprising one or more SQL statements) performed on the database to complete a common task and maintain data consistency. Transaction statements are closely related and perform interdependent actions. Each statement performs part of the task, but all of them are required for the complete task.

Transaction processing ensures that related data is added to or deleted from the database simultaneously, thus preserving data integrity in your application. In transaction processing, data is not written to the database until a commit command is issued. When this happens, data is permanently written to the database.

For example, if a transaction comprises database operations to update two database tables, either all updates are made to both tables, or no updates are made to either table. This condition guarantees that the data remains in a consistent state and the integrity of the data is maintained.

You see a consistent view of the database during a transaction. You do not see changes from other users during a transaction.

Transaction processing ensures that transaction are:

  • Atomic

    Either all database changes for an entire transaction are completed or none of the changes are completed.

  • Consistent

    Database changes transform from one consistent database state to another.

  • Isolated

    Transactions from concurrent applications do not interfere with each other. The updates from a transaction are not visible to other transactions that execute concurrently until the transaction commits.

  • Durable

    Complete database operations are permanently written to the database.