1.Easy
In PostgreSQL and MySQL, which clause returns only the first 10 rows of a result?
- AMAX 10
- BFIRST 10 ONLY
- CLIMIT 10
- DTOP ROWS 10
2.Easy
Which SQL statement changes values in rows that already exist?
- AREPLACE COLUMN
- BMODIFY
- CUPDATE
- DINSERT
3.Easy
Which SQL keyword removes duplicate rows from a result?
- ASINGLE
- BUNIQUE
- CDISTINCT
- DDIFFERENT
4.Medium
The orders table has 5 rows, each referring to an existing customer. The customers table has 3 rows. How many rows does an INNER JOIN on customer_id return?
- A5
- B3
- C8
- D15
5.Medium
Which query returns the highest salary in each department?
- ASELECT dept, MAX(salary) FROM emp ORDER BY dept
- BSELECT dept, salary FROM emp WHERE salary = MAX(salary)
- CSELECT dept, MAX(salary) FROM emp GROUP BY dept
- DSELECT MAX(dept), salary FROM emp GROUP BY salary
6.Medium
When is WHERE EXISTS (subquery) true for a row?
- AWhen the subquery returns a number greater than zero
- BWhen the subquery returns at least one row
- CWhen the subquery returns no NULL values
- DWhen the subquery returns exactly one row
7.Hard
Table enrolment(student_id, course_id, student_name, grade) has the key (student_id, course_id). Which normal form does it violate?
- AThird normal form only, because grade depends on student_name
- BFirst normal form, because the grade column does not hold atomic values
- CNone, it is in BCNF
- DSecond normal form, because student_name depends on student_id only
8.Hard
Two transactions both read stock = 10, each subtracts 1 and writes the result, giving 9 instead of 8. Which anomaly is this?
- ADeletion anomaly
- BDirty read
- CLost update
- DPhantom read
Answer key
- 1. C · LIMIT 10
- 2. C · UPDATE
- 3. C · DISTINCT
- 4. A · 5
- 5. C · SELECT dept, MAX(salary) FROM emp GROUP BY dept
- 6. B · When the subquery returns at least one row
- 7. D · Second normal form, because student_name depends on student_id only
- 8. C · Lost update
Full step-by-step solutions: practise this topic on examproblems.com.