1.Easy
How does UNION ALL differ from UNION?
- AUNION ALL only works on one table
- BUNION ALL removes duplicate rows
- CUNION ALL keeps duplicate rows
- DUNION ALL sorts the result
2.Easy
Which SQL statement changes values in rows that already exist?
- AMODIFY
- BINSERT
- CREPLACE COLUMN
- DUPDATE
3.Easy
What does ROLLBACK do in a transaction?
- ASaves all changes of the transaction permanently to disk
- BRepeats the last statement
- CUndoes the changes made since the transaction began
- DDeletes the table
4.Medium
Which query returns the highest salary in each department?
- ASELECT dept, salary FROM emp WHERE salary = MAX(salary)
- BSELECT dept, MAX(salary) FROM emp ORDER BY dept
- CSELECT dept, MAX(salary) FROM emp GROUP BY dept
- DSELECT MAX(dept), salary FROM emp GROUP BY salary
5.Medium
Why can a table have only one clustered index?
- AThe rows can be stored physically in only one order
- BClustered indexes use too much memory
- CClustered indexes can only be on the primary key
- DThe SQL standard forbids more than one index on a table
6.Medium
Third normal form (3NF) removes:
- ATransitive dependencies between non-key attributes
- BAtomic values
- CRedundant indexes on columns that are not part of a key
- DComposite keys
7.Hard
Two doctors on call each check that the other is still on call, then both sign off at the same time. Which anomaly can snapshot isolation still allow here?
- ADirty write
- BNon-repeatable read within one transaction
- CWrite skew
- DDirty read
8.Hard
An app runs UPDATE item SET qty = 4, version = 8 WHERE id = 1 AND version = 7, and reports a conflict if no row was updated. What technique is this?
- ADatabase sharding
- BOptimistic concurrency control
- CWrite-ahead logging
- DStrict two-phase locking with row locks
Answer key
- 1. C · UNION ALL keeps duplicate rows
- 2. D · UPDATE
- 3. C · Undoes the changes made since the transaction began
- 4. C · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 5. A · The rows can be stored physically in only one order
- 6. A · Transitive dependencies between non-key attributes
- 7. C · Write skew
- 8. B · Optimistic concurrency control
Full step-by-step solutions: practise this topic on examproblems.com.