MySQL Question - Unique Key Not functioning correctly, or am I misunderstanding?

前端 未结 5 1691
忘掉有多难
忘掉有多难 2020-12-16 15:30

I\'m trying to create a relation where any of four different parts may be included, but any collection of the same parts should be handled as unique.

Example: An ass

5条回答
  •  無奈伤痛
    2020-12-16 15:59

    This is a Feature (though not what I expected, either).

    This thread suggests making your key a Primary key to get the behavior you expected:

    This is a feature - a NULL value is an undefined value, therefore two NULL values are not the same. Can be a little confusing but makes sense when you think about it.

    A UNIQUE index does ensure that non-NULL values are unique; you could specify that your column not accept NULL values.

提交回复
热议问题