DML & Transactions · Question 8 · Medium
DML & Transactions question 8
Table Account:
acc_no | holder | balance
101 | Farah | 5000
102 | Gopal | 12000
103 | Hema | 800
104 | Imran | 7000
What does the SELECT return after these statements?
BEGIN;
UPDATE Account SET balance = balance - 1000
WHERE acc_no = 101;
ROLLBACK;
SELECT balance FROM Account WHERE acc_no = 101;
- 4000
- 6000
- NULL
- 5000
Answer and explanation
Answer: D. 5000
Explanation: The UPDATE happens inside a transaction that is then rolled back. ROLLBACK undoes every change made since BEGIN, so Farah's balance is back to 5000.
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
- During a UPI transfer, ₹500 is debited from Meena's account, but the credit to…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
- A session is in autocommit mode (the default in MySQL, PostgreSQL and SQLite)…
- Table Cart: item | qty Rice | 1 Which items does the SELECT return after these…
- Table Account: acc_no | holder | balance 101 | Farah | 5000 102 | Gopal |…
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