Quiz de 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.

Médio 10 perguntas ~6 minutos Aprovação com 80% SQLite

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 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;
Mostrar a resposta

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.

O que este quiz cobre

  • 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

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.