Transactions
A transaction groups statements so that either all of them happen or none do.
The classic example is a transfer: taking money from one account and adding it to another must not be separable. If the second statement fails and the first has already been applied, the money has simply gone.
Anything that would leave the data half-changed belongs in a transaction. Creating an order and its line items. Moving a record between tables. Applying a batch of corrections.
And do not leave one open. An uncommitted transaction holds locks, which means other work waits behind it. Commit or roll back promptly.
Mark this lesson complete
Signed in, your progress follows you to every device.