I have found a "problem" with UNIQUE in InnoDB.

Example:

mysql> CREATE TABLE b (
    ->   idB int(11) NOT NULL auto_increment,
    ->   valor int(11) default NULL,
    ->   PRIMARY KEY  (idB),
    ->   UNIQUE KEY valor (valor)
    -> ) TYPE=MyISAM;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT INTO b (idB, valor) VALUES (1,1),(2,2),(3,NULL),(4,NULL);
Query OK, 4 rows affected (0.01 sec)
Registros: 4  Duplicados: 0  Peligros: 0

mysql> select * from b;
+-----+-------+
| idB | valor |
+-----+-------+
|   1 |     1 |
|   2 |     2 |
|   3 |  NULL |
|   4 |  NULL |
+-----+-------+
4 rows in set (0.00 sec)

mysql> alter table b type=InnoDB;
ERROR 1062: Entrada duplicada 'NULL' para la clave 2


Why? I know that NULL != NULL, then behaviour in MyISAM is correct but
in InnoDB in not.

With "foreign key constraints", I have found the same problem: I can't
insert a NULL in a column that "references" other.

Thanks,
José Ceferino Ortega


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to