Can you insert a second NULL into a column with a UNIQUE constraint?
In PostgreSQL and MySQL, the column is defined as email VARCHAR(50) UNIQUE; in ClickHouse, it's email Nullable(String). User 2 has no email address. The query inserts another user without an email address, then retrieves all users with no email address. Will it run successfully?
Predict the resultDDL, keys, and normalizationJuniorBackendQAData Engineer
Input data · iv_users
| id | topics | |
|---|---|---|
| 1 | ann@example.com | sql,python |
| 2 | NULL | mysql |
| 3 | boris@example.com | python,sql |
| 4 | clara@example.com | nosql,go |
| 5 | dan@example.com | sql |
Query
INSERT INTO iv_users (id, email, topics) VALUES (6, NULL, 'go');
SELECT id, email
FROM iv_users
WHERE email IS NULL
ORDER BY id