Databases & SQL worksheet with answers
Free printable Databases & SQL worksheet: 8 problems from easy to exam level, with an answer key. Print it or save it as a PDF.
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 SQL statement retrieves data from a table?
- ACREATE
- BINSERT
- CSELECT
- DUPDATE
2.Easy
Which statement deletes a whole table, including its structure?
- ATRUNCATE ROWS
- BDELETE FROM
- CREMOVE TABLE
- DDROP TABLE
3.Easy
What does NULL represent in SQL?
- AThe number zero in numeric columns
- BA missing or unknown value
- CA false Boolean
- DAn empty string
4.Medium
What does GRANT SELECT ON employees TO alice do?
- AMakes alice the owner of the database
- BAllows alice to update and delete rows in the employees table
- CAllows the user alice to read the employees table
- DCopies the employees table to alice
5.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?
- A8
- B3
- C5
- D15
6.Medium
A table stores the customer's address on every order row. Changing the address in one row but not in the others is an example of:
- AAn update anomaly
- BA deletion anomaly
- CA phantom read
- DAn insertion anomaly
7.Hard
Two-phase locking (2PL) ensures:
- AConflict-serializable schedules
- BThat deadlocks can never happen
- CThat no locks are needed
- DThat transactions never wait
8.Hard
What does the following return: SELECT name FROM students WHERE grade > (SELECT AVG(grade) FROM students)?
- AAn error because subqueries are not allowed in WHERE
- BThe average grade of all students
- CStudents with a grade above the average grade
- DStudents with the highest grade only