3 ms·
> If you have a user table with a non-nullable email column and a nullable username column, and a uniqueness constraint on something like (email, username), you
by anarazel 2y ago
> If you have a user table with a non-nullable email column and a nullable username column, and a uniqueness constraint on something like (email, username), you'll be able to insert multiple identical emails with a null username into that table - because a null isn't equivalent to another null.
FWIW, since 15 postgres you can influence that behaviour with NULLS [NOT] DISTINCT for constraints and unique indexes.
https://www.postgresql.org/docs/devel/sql-createtable.html#SQL-CREATETABLE-PARMS-UNIQUE https://www.postgresql.org/docs/devel/sql-createtable.html#S...
EDIT: Added link