Atomicity means a transaction is treated as one complete action, not separate steps. All the operations inside it must succeed together, or else none of them are applied. If something goes wrong in between, the system cancels everything and returns to the original state so no partial changes remain.
Atomicity is what makes a wallet system reliable for me. I see every transfer as one complete action, not separate steps. Either the full transaction happens or nothing happens at all. If something fails in between, everything is cancelled, so no money is lost and no partial updates occurs.
BEGIN;
initiatiing a transaction by detucting money from Alice
UPDATE accounts
SET balance = balance - 200
WHERE name = 'Alice';
making a error intentionlly
UPDATE accounts
SET balance = balance + 200
WHERE name = 'Charlie'; (user Charlie does not exist)
COMMIT;
The Transaction does not take place and commit does not happen and rolledback
ROLLBACK;
Thus, Aliceโs balance remains unchanged and No partial deduction happens, This is Atomicity
Top comments (0)