1.Easy
What does COMMIT do in a transaction?
- AUndoes all changes made since the transaction began
- BStarts a new table
- CMakes all changes of the transaction permanent
- DLocks the whole database
2.Easy
Which aggregate function counts rows?
- ASUM
- BAVG
- CCOUNT
- DMAX
3.Easy
In PostgreSQL and MySQL, which clause returns only the first 10 rows of a result?
- AMAX 10
- BFIRST 10 ONLY
- CTOP ROWS 10
- DLIMIT 10
4.Medium
What does SELECT COALESCE(phone, 'unknown') FROM customers return for a customer whose phone is NULL?
- A'unknown'
- BAn empty string
- CNULL
- DAn error
5.Medium
Which ACID property guarantees that committed changes survive a system crash?
- AConsistency
- BAtomicity
- CDurability
- DIsolation
6.Medium
A LEFT JOIN returns:
- ARows that match in neither table
- BOnly matching rows from both tables
- CAll rows from the left table and matching rows from the right, with NULLs where there is no match
- DAll rows from the right table only
7.Hard
Which SQL feature is best suited to finding every employee below a manager in an organisation tree of unknown depth?
- AA GROUP BY on manager_id
- BA UNIQUE constraint on manager_id
- CA single self-join of the employees table on manager_id
- DA recursive common table expression (WITH RECURSIVE)
8.Hard
What does SELECT name, dept, AVG(salary) OVER (PARTITION BY dept) FROM emp return?
- AAn error because name is not in a GROUP BY
- BOnly employees who earn more than their department average
- CEvery employee row together with the average salary of their department
- DOne row per department with its average salary
Answer key
- 1. C · Makes all changes of the transaction permanent
- 2. C · COUNT
- 3. D · LIMIT 10
- 4. A · 'unknown'
- 5. C · Durability
- 6. C · All rows from the left table and matching rows from the right, with NULLs where there is no match
- 7. D · A recursive common table expression (WITH RECURSIVE)
- 8. C · Every employee row together with the average salary of their department
Full step-by-step solutions: practise this topic on examproblems.com.