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);
- 2, 4
- 3, 4
- 3, 2
- 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
- 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 |…
- Table Wallet: user_name | points Lalit | 100 Mona | NULL Nitin | 50 Every user…
- 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