DML & Transactions · Question 9 · Medium

DML & Transactions question 9

Table Account:
acc_no | holder | balance
101 | Farah | 5000
102 | Gopal | 12000
103 | Hema | 800
104 | Imran | 7000

Gopal sends ₹2,000 to Hema. What does the SELECT return after these statements?

BEGIN;
UPDATE Account SET balance = balance - 2000 WHERE acc_no = 102;
UPDATE Account SET balance = balance + 2000 WHERE acc_no = 103;
COMMIT;
SELECT acc_no, balance FROM Account
WHERE acc_no IN (102, 103) ORDER BY acc_no;
  1. 102, 10000; 103, 2800
  2. 102, 12000; 103, 800
  3. 102, 10000; 103, 800
  4. 102, 12000; 103, 2800
Answer and explanation

Answer: A. 102, 10000; 103, 2800

Explanation: Both UPDATEs are part of one transaction, and COMMIT makes both permanent together. Gopal goes from 12000 to 10000 and Hema from 800 to 2800; the total money is unchanged.

Previous: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |… · Next: Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…

Practise dml & transactions

Try a fresh set of dml & transactions questions with an explanation after every answer, free and without signing up: DML & Transactions practice. Or sit a full placement mock test.

More dml & transactions questions

More sql practice

SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge