Bug #6829 duplicate NULL values allowed in UNIQUE INDEX
| Submitted: | 25 Nov 2004 17:58 | Modified: | 26 Nov 2004 10:24 |
|---|---|---|---|
| Reporter: | Kirk Wylie | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 4.0.20 and 4.1.7 | OS: | Linux (Linux) |
| Assigned to: | CPU Architecture: | Any |
[25 Nov 2004 17:58]
Kirk Wylie
[25 Nov 2004 18:16]
Georg Richter
The SQL Standard allows multiple null values in unique constraints. Null is never equal to anything, even not to another null value.
[26 Nov 2004 0:49]
Paul DuBois
The multiple-NULL behavior is documented here: http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html Which says: In MySQL, a UNIQUE index is one in which all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. The exception to this is that if a column in the index is allowed to contain NULL values, it can contain multiple NULL values. This exception does not apply to BDB tables, for which indexed columns allow only a single NULL.
[26 Nov 2004 10:24]
Sergei Golubchik
Georg is right, the standard specifies: ... 2) If there are no two rows in T such that the value of each column in one row is non-null and is not distinct from the value of the corresponding column in the ther row, then the result of the <unique predicate> is True; otherwise, the result of the <unique predicate> is False. ... It explicitly says that rows where not "each column is non-null" is excluded from the uniqueness test.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.