Transactions and isolation
A transaction groups changes into one unit of work. Isolation governs what concurrent work can see and how conflicts are handled.
BEGIN, COMMIT and ROLLBACK
BEGIN starts a transaction. COMMIT makes its changes durable; ROLLBACK discards them. Updating several related records together prevents a partially applied business operation.
Safe changes
Preview the rows using a SELECT with the intended WHERE condition. Verify affected-row counts and final state. INSERT supplies new rows, UPDATE changes existing rows, and DELETE removes rows; all need the correct target grain.
Isolation and concurrency
Systems offer different implementations of read committed, repeatable read, snapshot or serializable behavior. Locks and multiversion concurrency control have trade-offs. A single-session browser lab cannot simulate two real competing client sessions.
Failure and recovery
Keep transactions short and handle errors and retries deliberately. Savepoints can roll back part of a transaction in supported engines. Avoid keeping a transaction open while waiting for a person to decide.