在某些情况下会产生任何问题吗?
这实际上在sqlite常见问题解答中.它是一种设计选择 – sqlite(与sql Server不同)选择多个NULL值不计入索引中的唯一性.
Perhaps you are referring to the following statement from sql92:
- A unique constraint is satisfied if and only if no two rows in a table have the same non-null values in the unique columns.
That statement is ambiguous,having at least two possible interpretations:
A unique constraint is satisfied if and only if no two rows in a table have the same values and have non-null values in the unique columns.
A unique constraint is satisfied if and only if no two rows in a table have the same values in the subset of unique columns that are not null.
sqlite follows interpretation (1),as does Postgresql,MysqL,Oracle,and Firebird. It is true that Informix and Microsoft sql Server use interpretation (2),however we the sqlite developers hold that interpretation (1) is the most natural reading of the requirement and we also want to maximize compatibility with other sql database engines,and most other database engines also go with (1),so that is what sqlite does.