A transaction is a group of statements that are saved together (COMMIT) or cancelled together (ROLLBACK). It needs the InnoDB engine.
START TRANSACTION;
UPDATE accounts SET balance = balance - 200 WHERE id = 1;
UPDATE accounts SET balance = balance + 200 WHERE id = 2;
COMMIT;
| ACID | Meaning |
|---|
| Atomicity | All or nothing |
| Consistency | Data stays valid |
| Isolation | Transactions do not disturb each other |
| Durability | Saved data survives a crash |
See MySQL Transactions.
Learn more about the similar topics:
| Tutorials |
| No Content Found. |
| Exercises & Assignments |
| No Content Found. |
| Interview Questions & Answers |
| No Content Found. |