Chapter 4. Transactions and Locks
The SQL-99 specification defines transaction in this way:
"An SQL-transaction (transaction) is a sequence of executions of SQL-statements that is atomic with respect to recovery. That is to say: either the execution result is completely successful, or it has no effect on any SQL-schemas or SQL-data.
The SQL Standard"
So, a transaction is an important feature that guarantees the integrity of data. It is useful to prevent the data from remaining in an inconsistent state when an operation fails. Suppose, for example, we are administering a database for an e-commerce website. We have several tables; one of them stores the orders, and the others store the available products and their quantity. When a customer buys a product, a new order must be written in the appropriate table and the quantity of that product must decrease. These operations must occur within the same transaction. In this way, if a server crashes after the order has been written...