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?

  1. AINSERT
  2. BUPDATE
  3. CSELECT
  4. DCREATE
2.Easy

What does a CROSS JOIN return?

  1. AOnly rows that do not match
  2. BThe rows of the first table only
  3. COnly the rows that match on a shared key column
  4. DEvery combination of rows from the two tables
3.Easy

What does COMMIT do in a transaction?

  1. AStarts a new table
  2. BUndoes all changes made since the transaction began
  3. CLocks the whole database
  4. DMakes all changes of the transaction permanent
4.Medium

What is SQL injection?

  1. AA database backup technique
  2. BA technique for inserting many rows quickly with a single INSERT statement
  3. CA way to add indexes
  4. DAn attack where user input changes the structure of a SQL query
5.Medium

First normal form (1NF) requires that:

  1. AEvery table has exactly one column
  2. BEach column contains atomic values and there are no repeating groups
  3. CEvery non-key column depends on the whole key and on nothing but the key
  4. DThere are no foreign keys
6.Medium

Which ACID property guarantees that committed changes survive a system crash?

  1. AAtomicity
  2. BIsolation
  3. CConsistency
  4. DDurability
7.Hard

Table employee(emp_id, dept_id, dept_name) has the key emp_id, and dept_id → dept_name. Which statement is correct?

  1. AIt is not in 1NF
  2. BIt is in BCNF and therefore in 3NF
  3. CIt is in 2NF but not in 3NF
  4. DIt is not in 2NF
8.Hard

With multiversion concurrency control (MVCC), how can readers avoid blocking writers?

  1. AReaders see a consistent snapshot of committed row versions while writers create new versions
  2. BReaders always wait until all writers have committed
  3. CWriters are not allowed while any reader is active
  4. DReaders read uncommitted data directly

Answer key

  1. 1. C · SELECT
  2. 2. D · Every combination of rows from the two tables
  3. 3. D · Makes all changes of the transaction permanent
  4. 4. D · An attack where user input changes the structure of a SQL query
  5. 5. B · Each column contains atomic values and there are no repeating groups
  6. 6. D · Durability
  7. 7. C · It is in 2NF but not in 3NF
  8. 8. A · Readers see a consistent snapshot of committed row versions while writers create new versions

Full step-by-step solutions: practise this topic on examproblems.com.