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 rows does WHERE price BETWEEN 10 AND 20 select?

  1. ARows with price outside the range 10 to 20
  2. BRows with price equal to 10 or 20 only
  3. CRows with price above 10 and below 20, excluding 10 and 20
  4. DRows with price from 10 to 20, including 10 and 20
2.Easy

Which SQL keyword removes duplicate rows from a result?

  1. ASINGLE
  2. BDISTINCT
  3. CUNIQUE
  4. DDIFFERENT
3.Easy

Which SQL statement retrieves data from a table?

  1. AUPDATE
  2. BCREATE
  3. CINSERT
  4. DSELECT
4.Medium

Why can a table have only one clustered index?

  1. AThe SQL standard forbids more than one index on a table
  2. BClustered indexes use too much memory
  3. CThe rows can be stored physically in only one order
  4. DClustered indexes can only be on the primary key
5.Medium

What does GRANT SELECT ON employees TO alice do?

  1. ACopies the employees table to alice
  2. BAllows alice to update and delete rows in the employees table
  3. CMakes alice the owner of the database
  4. DAllows the user alice to read the employees table
6.Medium

Third normal form (3NF) removes:

  1. AComposite keys
  2. BTransitive dependencies between non-key attributes
  3. CAtomic values
  4. DRedundant indexes on columns that are not part of a key
7.Hard

Why might a query with WHERE YEAR(order_date) = 2025 not use an index on order_date?

  1. AApplying a function to the column prevents a simple index range lookup
  2. BIndexes never work with dates
  3. CYEAR is not valid SQL
  4. DAn index on order_date is only used for ORDER BY clauses, never for WHERE
8.Hard

Which isolation level prevents dirty reads but still allows non-repeatable reads?

  1. ARepeatable read
  2. BRead committed
  3. CSerializable
  4. DRead uncommitted

Answer key

  1. 1. D · Rows with price from 10 to 20, including 10 and 20
  2. 2. B · DISTINCT
  3. 3. D · SELECT
  4. 4. C · The rows can be stored physically in only one order
  5. 5. D · Allows the user alice to read the employees table
  6. 6. B · Transitive dependencies between non-key attributes
  7. 7. A · Applying a function to the column prevents a simple index range lookup
  8. 8. B · Read committed

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