1.Easy
An INNER JOIN returns:
- AOnly rows with matching values in both tables
- BAll rows from both tables
- CRows that do not match
- DAll rows from the left table, with NULLs where there is no match
2.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
3.Easy
Which aggregate function returns the average of a numeric column?
- AMEDIAN
- BSUM
- CMEAN
- DAVG
4.Medium
A view in SQL is:
- AA stored query that behaves like a virtual table
- BA copy of a table on disk
- CA screen in the database client for browsing tables
- DAn index type
5.Medium
A table has rows where col is NULL. Which rows does WHERE col = NULL return?
- AOnly the rows where col is NULL, as with IS NULL
- BAll rows of the table
- CNo rows, because the comparison is unknown
- DAn error in every database
6.Medium
What is a database trigger?
- AA query that a user runs by hand
- BA scheduled backup of the database
- CCode that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
- DA type of index that speeds up searches
7.Hard
What does the following return: SELECT name FROM students WHERE grade > (SELECT AVG(grade) FROM students)?
- AStudents with the highest grade only
- BStudents with a grade above the average grade
- CAn error because subqueries are not allowed in WHERE
- DThe average grade of all students
8.Hard
What does EXPLAIN (or EXPLAIN ANALYZE in PostgreSQL) show for a query?
- AThe list of users who ran the query
- BA rewrite of the query in relational algebra notation only
- CThe execution plan chosen by the optimiser, such as scans and join methods
- DThe meaning of each SQL keyword in the query
Answer key
- 1. A · Only rows with matching values in both tables
- 2. C · UNION ALL keeps duplicate rows
- 3. D · AVG
- 4. A · A stored query that behaves like a virtual table
- 5. C · No rows, because the comparison is unknown
- 6. C · Code that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
- 7. B · Students with a grade above the average grade
- 8. C · The execution plan chosen by the optimiser, such as scans and join methods
Full step-by-step solutions: practise this topic on examproblems.com.