[ACCEPTED]-Unique constraint that allows empty values in MySQL-constraints
Accepted answer
Yes, you can do this. See the MySQL reference (version 5.5).
A UNIQUE 7 index creates a constraint such that all 6 values in the index must be distinct. An 5 error occurs if you try to add a new row 4 with a key value that matches an existing 3 row. For all engines, a UNIQUE index allows 2 multiple NULL values for columns that can 1 contain NULL.
Yes, if you make the product code column 3 nullable (not declared with NOT NULL
), the unique 2 key will allow multiple rows with NULL
product 1 codes.
MySQL still allows for multiple rows to 1 have a value of NULL
in a unique column.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.