UPDATE cuentas SET saldo = saldo - 100 WHERE id_cliente = 1; UPDATE cuentas SET saldo = saldo + 100 WHERE id_cliente = 2;
Transactions are atomic units of work that can be committed or rolled back. When a transaction makes multiple changes to the database, either all the changes succeed when the transaction is committed, or all the changes are undone when the transaction is rolled back.
Database transactions, as implemented by
InnoDB, have properties that are collectively known by the acronym ACID, for atomicity, consistency, isolation, and durability.
To disable autocommit mode explicitly, use the following statement:
To disable autocommit mode implicitly for a single series of statements, use the
START TRANSACTION statement:
START TRANSACTION; SELECT @A:=SUM(salary) FROM table1 WHERE type=1; UPDATE table2 SET summary=@A WHERE type=1; COMMIT;
START TRANSACTION, autocommit remains disabled until you end the transaction with
ROLLBACK. The autocommit mode then reverts to its previous state.
InnoDB offers all four transaction isolation levels described by the SQL:1992 standard:
REPEATABLE READ, and
SERIALIZABLE. The default isolation level for
¿Se puede cambiar la configuración del aislamiento por defecto de MySQL? ¿Cómo se hace?