Transactions
- Performing transactions
- Using savepoints
- Isolation levels
- Locking
Introduction
Transaction means a set of SQL statements that should succeed or fail together. Transactions should also satisfy Atomicity, Consistency, Isolation, andDurability(ACID) properties.
- Atomicity: Either all the SQLs should be successful or all should fail. There should not be any partial updates.
- Consistency: A transaction must change affected data only in allowed ways.
- Isolation: Transactions that occur at the same time (concurrent transactions) should not lead the database to an inconsistent state. Each of the transactions should be executed as if it were the only transaction in the system. No transaction should affect the existence of any other transaction.
- Durability: The data should be persistent on disk and should not be lost despite any database or system failure.
InnoDB, the default storage engine in MySQL, supports transactions whereas MyISAM does not support them.