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 keyword gives a column or table a temporary alternative name in a query?

  1. ANAME
  2. BAS
  3. CALIAS
  4. DRENAME
2.Easy

What is a primary key?

  1. AA column that may hold duplicate values but must never contain NULL
  2. BA password for the database
  3. CA column or set of columns that uniquely identifies each row
  4. DThe first column of every table
3.Easy

Which SQL statement changes values in rows that already exist?

  1. AINSERT
  2. BREPLACE COLUMN
  3. CUPDATE
  4. DMODIFY
4.Medium

What is a database trigger?

  1. ACode that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
  2. BA type of index that speeds up searches
  3. CA scheduled backup of the database
  4. DA query that a user runs by hand
5.Medium

Third normal form (3NF) removes:

  1. AComposite keys
  2. BRedundant indexes on columns that are not part of a key
  3. CTransitive dependencies between non-key attributes
  4. DAtomic values
6.Medium

Why can a table have only one clustered index?

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

Table b contains the values 1, 2 and NULL in column y. What does SELECT * FROM a WHERE x NOT IN (SELECT y FROM b) return?

  1. ANo rows at all
  2. BRows of a where x is not 1 or 2
  3. CEvery row of a
  4. DOnly rows of a where x is NULL
8.Hard

What does a FULL OUTER JOIN return?

  1. AThe Cartesian product, pairing each row of one table with every row of the other
  2. BAll rows from both tables, matched where possible and NULL-filled otherwise
  3. COnly unmatched rows
  4. DOnly matching rows

Answer key

  1. 1. B · AS
  2. 2. C · A column or set of columns that uniquely identifies each row
  3. 3. C · UPDATE
  4. 4. A · Code that runs automatically when a specified event such as INSERT, UPDATE or DELETE occurs on a table
  5. 5. C · Transitive dependencies between non-key attributes
  6. 6. B · The rows can be stored physically in only one order
  7. 7. A · No rows at all
  8. 8. B · All rows from both tables, matched where possible and NULL-filled otherwise

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