For teachers: free to print, copy and use in class. Every new worksheet has new values and its own answer key. A link to ExamProblems on your course page is appreciated.
Name: ____________________ Date: ____________
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
How does UNION ALL differ from UNION?
AUNION ALL keeps duplicate rows
BUNION ALL only works on one table
CUNION ALL removes duplicate rows
DUNION ALL sorts the result
3.Easy
Which aggregate function returns the average of a numeric column?
AMEAN
BSUM
CMEDIAN
DAVG
4.Medium
Why does SELECT price * 2 AS double_price FROM t WHERE double_price > 10 fail in most databases?
AArithmetic is not allowed in the SELECT list
BWHERE is evaluated before the SELECT list, so the alias does not exist yet
CWHERE can only compare text columns
DAliases may not contain an underscore
5.Medium
Students can take many courses and courses have many students. How is this modelled in tables?
ABy merging students and courses into one table
BWith a junction table holding foreign keys to both students and courses
CWith a foreign key column course_id in the students table pointing to courses
DWith a list of course ids stored in one column
6.Medium
What is a database trigger?
AA type of index that speeds up searches
BCode that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
CA query that a user runs by hand
DA scheduled backup of the database
7.Hard
Scores are 90, 90 and 80. Which values does RANK() OVER (ORDER BY score DESC) give?
A1, 2, 3
B1, 1, 3
C2, 2, 3
D1, 1, 2
8.Hard
What is the result of SELECT COUNT(col) FROM t if all values in col are NULL and the table has 10 rows?
AAn error
B0
C10
DNULL
Answer key
1. C · Makes all changes of the transaction permanent
2. A · UNION ALL keeps duplicate rows
3. D · AVG
4. B · WHERE is evaluated before the SELECT list, so the alias does not exist yet
5. B · With a junction table holding foreign keys to both students and courses
6. B · Code that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
7. B · 1, 1, 3
8. B · 0
Full step-by-step solutions: practise this topic on examproblems.com.