1.Easy
What does UNION do with the results of two SELECT queries?
- AJoins them side by side on a key
- BKeeps only rows that appear in both
- CCombines them into one result and removes duplicate rows
- DKeeps only rows that appear in the first query but not the second
2.Easy
What does ROLLBACK do in a transaction?
- AUndoes the changes made since the transaction began
- BRepeats the last statement
- CSaves all changes of the transaction permanently to disk
- DDeletes the table
3.Easy
Which statement adds a new column to an existing table?
- ACREATE COLUMN
- BINSERT COLUMN
- CALTER TABLE
- DUPDATE TABLE
4.Medium
In relational algebra, the selection operator (σ) corresponds to which SQL clause?
- AWHERE
- BSELECT list
- CGROUP BY
- DORDER BY
5.Medium
Which query lists customers who have never placed an order?
- ASELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NOT NULL
- BSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- CSELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id = NULL
- DSELECT c.name FROM customers c INNER JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
6.Medium
A table has rows where col is NULL. Which rows does WHERE col = NULL return?
- AAn error in every database
- BNo rows, because the comparison is unknown
- CAll rows of the table
- DOnly the rows where col is NULL, as with IS NULL
7.Hard
What does SELECT name, dept, AVG(salary) OVER (PARTITION BY dept) FROM emp return?
- AEvery employee row together with the average salary of their department
- BOne row per department with its average salary
- CAn error because name is not in a GROUP BY
- DOnly employees who earn more than their department average
8.Hard
What is a known drawback of decomposing tables into BCNF compared with 3NF?
- ABCNF tables cannot have primary keys
- BSome functional dependencies may no longer be checkable within a single table
- CBCNF allows more redundancy than 3NF
- DThe decomposition always loses data when joined back
Answer key
- 1. C · Combines them into one result and removes duplicate rows
- 2. A · Undoes the changes made since the transaction began
- 3. C · ALTER TABLE
- 4. A · WHERE
- 5. B · SELECT c.name FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.id IS NULL
- 6. B · No rows, because the comparison is unknown
- 7. A · Every employee row together with the average salary of their department
- 8. B · Some functional dependencies may no longer be checkable within a single table
Full step-by-step solutions: practise this topic on examproblems.com.