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
Which operator is used for simple text pattern matching in a WHERE clause?
ALIKE
BCONTAINS
CMATCH
DSIMILAR
2.Easy
How do you sort a result from the highest to the lowest salary?
AORDER BY salary DESC
BGROUP BY salary DESC
CSORT salary DOWN
DORDER BY salary ASC
3.Easy
What is a composite key?
AA key made up of two or more columns
BA key stored in a separate table
CA key that is generated by the database
DA key that allows duplicate values
4.Medium
Which query returns the number of different cities in the customers table?
ASELECT COUNT(city) FROM customers GROUP BY city
BSELECT SUM(DISTINCT city) FROM customers
CSELECT DISTINCT COUNT(city) FROM customers
DSELECT COUNT(DISTINCT city) FROM customers
5.Medium
What is a database trigger?
ACode that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
BA scheduled backup of the database
CA type of index that speeds up searches
DA query that a user runs by hand
6.Medium
Table a has 3 rows and table b has 4 rows. How many rows does SELECT * FROM a CROSS JOIN b return?
A4
B12
C3
D7
7.Hard
What does the write-ahead logging (WAL) rule require?
AThe log is written only after a crash
BEvery query must be logged before it is parsed
CData pages must be written before the log
DA change's log record must reach stable storage before the changed data page does
8.Hard
What does EXPLAIN (or EXPLAIN ANALYZE in PostgreSQL) show for a query?
AThe list of users who ran the query
BThe execution plan chosen by the optimiser, such as scans and join methods
CA rewrite of the query in relational algebra notation only
DThe meaning of each SQL keyword in the query
Answer key
1. A · LIKE
2. A · ORDER BY salary DESC
3. A · A key made up of two or more columns
4. D · SELECT COUNT(DISTINCT city) FROM customers
5. A · Code that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
6. B · 12
7. D · A change's log record must reach stable storage before the changed data page does
8. B · The execution plan chosen by the optimiser, such as scans and join methods
Full step-by-step solutions: practise this topic on examproblems.com.