In PostgreSQL 18, a table is created as CREATE TABLE c1 (x int UNIQUE); and two rows are then inserted, both with x set to NULL. What happens?
The second insert fails with a unique violation
Both rows are stored✓Correct answer
The CREATE TABLE fails, because a UNIQUE column must also be NOT NULL
The second insert is accepted but silently discarded
Explanation
By default two null values are not considered equal for uniqueness, so a UNIQUE column can hold any number of null rows. This is why a nullable UNIQUE column is not a safe way to enforce at most one row per entity, and why this default is worth stating explicitly in a schema.