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 changes values in rows that already exist?

  1. AREPLACE COLUMN
  2. BMODIFY
  3. CUPDATE
  4. DINSERT
2.Easy

What is an entity-relationship (ER) diagram used for?

  1. AModelling entities, their attributes and relationships when designing a database
  2. BListing the users of a database
  3. CMeasuring database performance
  4. DShowing how a query is executed
3.Easy

In the relational model, what is a row of a table called?

  1. AA domain
  2. BA tuple
  3. CAn attribute
  4. DA schema
4.Medium

What does SELECT COALESCE(phone, 'unknown') FROM customers return for a customer whose phone is NULL?

  1. AAn empty string
  2. BNULL
  3. CAn error
  4. D'unknown'
5.Medium

What does EXCEPT (called MINUS in Oracle) return?

  1. ARows of the first query that do not appear in the second
  2. BAll rows from both queries without duplicates
  3. CRows that appear in both queries
  4. DRows of the second query that do not appear in the first one
6.Medium

Why are indexes created on columns?

  1. ATo speed up searches and joins on those columns
  2. BTo make inserts and updates faster on those columns
  3. CTo save disk space
  4. DTo prevent NULL values
7.Hard

Which window function assigns 1, 2, 3, ... to rows within each partition without ties?

  1. ACOUNT()
  2. BRANK()
  3. CDENSE_RANK()
  4. DROW_NUMBER()
8.Hard

Two doctors on call each check that the other is still on call, then both sign off at the same time. Which anomaly can snapshot isolation still allow here?

  1. AWrite skew
  2. BNon-repeatable read within one transaction
  3. CDirty read
  4. DDirty write

Answer key

  1. 1. C · UPDATE
  2. 2. A · Modelling entities, their attributes and relationships when designing a database
  3. 3. B · A tuple
  4. 4. D · 'unknown'
  5. 5. A · Rows of the first query that do not appear in the second
  6. 6. A · To speed up searches and joins on those columns
  7. 7. D · ROW_NUMBER()
  8. 8. A · Write skew

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