DML & Transactions · Question 10 · Medium

DML & Transactions question 10

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

Table Archive:
acc_no | holder
90 | Zubin

After the INSERT below, how many rows do Archive and Account hold, in that order?

INSERT INTO Archive (acc_no, holder)
SELECT acc_no, holder FROM Account
WHERE balance > 6000;
SELECT (SELECT COUNT(*) FROM Archive),
       (SELECT COUNT(*) FROM Account);
  1. 2, 4
  2. 3, 4
  3. 3, 2
  4. 2, 2
Answer and explanation

Answer: B. 3, 4

Explanation: INSERT ... SELECT copies the rows returned by the SELECT; it does not move them. Gopal and Imran have balances above 6000, so Archive grows from 1 row to 3, while Account keeps all 4 rows.

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