🔷 Introduction to ACID Properties in SQL Transactions
In SQL databases, a transaction is a sequence of one or more SQL operations (like INSERT, UPDATE, or DELETE) executed as a single unit of work.
To ensure the reliability and consistency of data, transactions must follow the ACID properties.
1.Create a table Accounts(acc_no INT PRIMARY KEY, name VARCHAR(50), balance INT). Insert 3 sample rows.
2.Atomicity: Start a transaction that transfers money. Rollback midway → ensure no partial update remains.
3.Consistency: Try inserting a record with negative balance → should be rejected.
4.Isolation: Run two sessions at once – one updating, the other reading → observe isolation.
Durability: Commit a transaction → restart DB → ensure data persists.
Top comments (0)