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

GRANT and REVOKE belong to which part of SQL?

  1. AData Manipulation Language (DML)
  2. BData Control Language (DCL)
  3. CData Query Language (DQL)
  4. DData Definition Language (DDL)
2.Easy

What does a CROSS JOIN return?

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

In a LIKE pattern, what does the % wildcard stand for?

  1. AAny sequence of zero or more characters
  2. BAny single digit
  3. CExactly one character in that position of the string
  4. DThe end of the string
4.Medium

Which ACID property means concurrent transactions do not see each other's unfinished changes?

  1. AAvailability
  2. BIsolation
  3. CDurability
  4. DAtomicity
5.Medium

What does ROLLBACK TO SAVEPOINT s1 do?

  1. AUndoes the whole transaction from the beginning
  2. BUndoes the changes made after savepoint s1, keeping the transaction open
  3. CDeletes the savepoint and all tables changed since then
  4. DEnds the transaction and commits everything
6.Medium

A view in SQL is:

  1. AA stored query that behaves like a virtual table
  2. BA screen in the database client for browsing tables
  3. CAn index type
  4. DA copy of a table on disk
7.Hard

When is a schedule of concurrent transactions called serializable?

  1. AWhen every transaction is given a serial number
  2. BWhen no transaction ever reads data
  3. CWhen the transactions run on one CPU only
  4. DWhen its effect is equivalent to some serial execution of the same transactions
8.Hard

R(A, B, C, D) has the functional dependencies A → B and C → D. What is the candidate key?

  1. A{A, C}
  2. B{C}
  3. C{B, D}
  4. D{A}

Answer key

  1. 1. B · Data Control Language (DCL)
  2. 2. B · Every combination of rows from the two tables
  3. 3. A · Any sequence of zero or more characters
  4. 4. B · Isolation
  5. 5. B · Undoes the changes made after savepoint s1, keeping the transaction open
  6. 6. A · A stored query that behaves like a virtual table
  7. 7. D · When its effect is equivalent to some serial execution of the same transactions
  8. 8. A · {A, C}

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