Quiz di SQL: 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.

Medio 10 domande ~6 minuti Superato con il 80% SQLite

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 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;
Mostra la risposta

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.

Cosa copre questo 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.