This content originally appeared on DEV Community and was authored by SRIRAM PG
CREATE TABLE Accounts (
acc_no INT PRIMARY KEY,
name VARCHAR(50),
balance INT
);
INSERT INTO Accounts VALUES
(1, 'Alice', 1000),
(2, 'Bob', 1500),
(3, 'Charlie', 2000);
SELECT * FROM Accounts;
Step-1: Atomicity & Rollback
Step-2: Deadlock Simulation
Session 1
UPDATE Accounts SET balance = balance - 100 WHERE name = 'Alice';
UPDATE Accounts SET balance = balance + 100 WHERE name = 'Bob';
Session 2
UPDATE Accounts SET balance = balance - 100 WHERE name = 'Bob';
UPDATE Accounts SET balance = balance + 100 WHERE name = 'Alice';
One of the sessions will show:
ORA-00060: deadlock detected while waiting for resource
Step-3: Log-Based Recovery
This content originally appeared on DEV Community and was authored by SRIRAM PG

SRIRAM PG | Sciencx (2025-10-05T17:12:15+00:00) Transactions, Deadlocks & Log Based Recovery. Retrieved from https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.