1.Easy
In PostgreSQL and MySQL, which clause returns only the first 10 rows of a result?
- AMAX 10
- BLIMIT 10
- CFIRST 10 ONLY
- DTOP ROWS 10
2.Easy
What does COMMIT do in a transaction?
- ALocks the whole database
- BUndoes all changes made since the transaction began
- CStarts a new table
- DMakes all changes of the transaction permanent
3.Easy
A foreign key is:
- AA key that is always encrypted
- BA column whose values must be unique across all rows of the table
- CA key used by foreign users
- DA column that refers to the primary key of another table
4.Medium
What does SELECT name, CASE WHEN grade >= 5.5 THEN 'pass' ELSE 'fail' END FROM results return?
- AThe number of students who passed and failed
- BEach name with the label 'pass' or 'fail' depending on the grade
- CAn error because CASE is not allowed in SELECT
- DOnly the students who passed
5.Medium
What does SELECT SUM(amount) FROM orders return when the WHERE clause matches no rows?
- ANULL
- BAn empty string
- C0
- DAn error
6.Medium
Which ACID property guarantees that committed changes survive a system crash?
- AConsistency
- BDurability
- CAtomicity
- DIsolation
7.Hard
Which window function assigns 1, 2, 3, ... to rows within each partition without ties?
- AROW_NUMBER()
- BDENSE_RANK()
- CCOUNT()
- DRANK()
8.Hard
Scores are 90, 90 and 80. Which values does RANK() OVER (ORDER BY score DESC) give?
- A1, 1, 2
- B2, 2, 3
- C1, 2, 3
- D1, 1, 3
Answer key
- 1. B · LIMIT 10
- 2. D · Makes all changes of the transaction permanent
- 3. D · A column that refers to the primary key of another table
- 4. B · Each name with the label 'pass' or 'fail' depending on the grade
- 5. A · NULL
- 6. B · Durability
- 7. A · ROW_NUMBER()
- 8. D · 1, 1, 3
Full step-by-step solutions: practise this topic on examproblems.com.