+ 1
Does a unique constraint allows a null value to be inserted once? Or the Check constraint
2 Antworten
+ 2
This may surprise you but In MySQL, yes. More than once even. You could repeatedly insert null into a unique-constrained field and MySQL would not complain.
If you had a composite unique constraint, in other words a unique constraint spanning multiple fields, a null in any of the fields causes this behaviour too.
There is more discussion on that here:
https://stackoverflow.com/questions/3712222/does-mysql-ignore-null-values-on-unique-constraints
Most of my experience is with MySQL and I didn't quickly find conclusive information on if other vendors such as Postgres and Oracle do the same.
+ 1
How about the check constraint?