In PostgreSQL 18, a table is created as CREATE TABLE c4 (a int, b int, UNIQUE (a, b)); and the row (1, NULL) is inserted twice. What happens?
Both rows are stored✓Correct answer
The second insert fails with a unique violation
The second insert fails only when every column of the key is null
It raises an error, because a multi-column UNIQUE key may not contain nulls
Explanation
A multi-column unique constraint is violated only when the values of all constrained columns are equal, and a null in b is not equal to another null, so a single nullable column is enough to defeat the constraint even though a is duplicated. The constraint is otherwise active: inserting (1, 5) twice is rejected.