5 ms·
If it can't be either behavior, then should nullable columns not be allowed in unique indexes at all?
by Dylan16807 4y ago
If it can't be either behavior, then should nullable columns not be allowed in unique indexes at all?
- masklinn 4y agoA few DBs actually do that. It can be rather limiting, though also less surprising (at runtime) than either other behaviour.
- SoftTalker 4y agoNo ideally not. If they are they must be ignored. If other columns in the row index are unique regardless of the value of the nullable column, then the row is logically unique. So if in that case the NULL value is ignored, then OK. But two NULLs neither match each other nor are they distinct from each other. You just cannot say either way.