SQL-Quiz: Constraints & Keys

This SQL quiz tests the constraints that keep bad data out of your tables. You will decide which inserts and deletes fail, how primary and foreign keys behave, and where SQLite, MySQL and PostgreSQL disagree.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% SQLite

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 10

What happens when this runs?

CREATE TABLE users (id INTEGER PRIMARY KEY, email TEXT NOT NULL);
INSERT INTO users (id) VALUES (1);
SELECT COUNT(*) FROM users;
Lösung zeigen

A. Error email has no default, so leaving it out would store NULL, which NOT NULL rejects. The insert fails with a constraint error instead of quietly saving an empty email.

Darum geht es in diesem Quiz

  • NOT NULL, UNIQUE and CHECK constraints
  • Primary keys, composite keys and auto-generated ids
  • Foreign keys and ON DELETE CASCADE
  • Upserts with ON CONFLICT ... DO UPDATE
  • Engine differences, like SQLite's foreign key switch

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.