[ACCEPTED]-Unique constraint that allows empty values in MySQL-constraints
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.
More Related questions