Transactions, Deadlocks & Log Based Recovery

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…


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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » Transactions, Deadlocks & Log Based Recovery." SRIRAM PG | Sciencx - Sunday October 5, 2025, https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/
HARVARD
SRIRAM PG | Sciencx Sunday October 5, 2025 » Transactions, Deadlocks & Log Based Recovery., viewed ,<https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/>
VANCOUVER
SRIRAM PG | Sciencx - » Transactions, Deadlocks & Log Based Recovery. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/
CHICAGO
" » Transactions, Deadlocks & Log Based Recovery." SRIRAM PG | Sciencx - Accessed . https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/
IEEE
" » Transactions, Deadlocks & Log Based Recovery." SRIRAM PG | Sciencx [Online]. Available: https://www.scien.cx/2025/10/05/transactions-deadlocks-log-based-recovery-4/. [Accessed: ]
rf:citation
» Transactions, Deadlocks & Log Based Recovery | SRIRAM PG | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.