Unique key with NULLs

前端 未结 10 804
一整个雨季
一整个雨季 2020-12-03 00:48

This question requires some hypothetical background. Let\'s consider an employee table that has columns name, date_of_birth, tit

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 01:23

    I think MySQL does it right here. Some other databases (for example Microsoft SQL Server) treat NULL as a value that can only be inserted once into a UNIQUE column, but personally I find this to be strange and unexpected behaviour.

    However since this is what you want, you can use some "magic" value instead of NULL, such as a date a long time in the past

提交回复
热议问题