RE: UNIQUE KEY vs NULLs

2006-12-11 Thread imre
> From: Dan Buettner [mailto:[EMAIL PROTECTED] > This is a feature - a NULL value is an undefined value, > therefore two NULL values are not the same. Can be a little > confusing but makes sense when you think about it. > > A UNIQUE index does ensure that non-NULL values are unique; > you co

Re: UNIQUE KEY vs NULLs

2006-12-11 Thread Martijn Tonies
> I have an InnoDB table similar to this: > > CREATE TABLE Target > (IMSI VARCHAR(15) ASCII, > IMEI VARCHAR(15) ASCII, > UNIQUE KEY (IMSI, IMEI)); > > After playing a bit with it, I managed to add duplicate records, if one of > the fields was a NULL: > > +-+-+ > |

Re: UNIQUE KEY vs NULLs

2006-12-11 Thread Dan Buettner
This is a feature - a NULL value is an undefined value, therefore two NULL values are not the same. Can be a little confusing but makes sense when you think about it. A UNIQUE index does ensure that non-NULL values are unique; you could specify that your column not accept NULL values. Dan On

RE: UNIQUE KEY vs NULLs

2006-12-11 Thread emierzwa
It is expected behavior, you can make the unique key a primary key instead. This should prevent this situation. Ed -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, December 11, 2006 7:42 AM To: mysql@lists.mysql.com Subject: UNIQUE KEY vs NULLs Hi, I

UNIQUE KEY vs NULLs

2006-12-11 Thread imre
Hi, I have an InnoDB table similar to this: CREATE TABLE Target (IMSI VARCHAR(15) ASCII, IMEI VARCHAR(15) ASCII, UNIQUE KEY (IMSI, IMEI)); After playing a bit with it, I managed to add duplicate records, if one of the fields was a NULL: +-+-+ | IMSI