MySQL consentirà il valore NULL se non si specifica NOT NULL
nella definizione della colonna.
Ecco un test rapido:
mysql> create table test (id serial, field ENUM('Y','N') DEFAULT 'N');
Query OK, 0 rows affected (0.01 sec)
mysql> INSERT INTO test (field) VALUES ('Y');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test (field) VALUES ('N');
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test() VALUES();
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test (field) VALUES (NULL);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO test (field) VALUES ('Invalid');
Query OK, 1 row affected, 1 warning (0.01 sec)
mysql> show warnings;
+---------+------+--------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------+
| Warning | 1265 | Data truncated for column 'field' at row 1 |
+---------+------+--------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from test;
+----+-------+
| id | field |
+----+-------+
| 1 | Y |
| 2 | N |
| 3 | N |
| 4 | NULL |
| 5 | |
+----+-------+
5 rows in set (0.00 sec)
Così MySQL fa rispettare il valore di default, ma permette anche NULL. (È interessante notare che troncherà valori non validi e consentire le stringhe vuote pure, ma questo è un problema diverso)
fonte
2010-01-13 18:29:14
lettura http://dev.mysql.com/doc/refman/5.1/en/enum.html ("Se una colonna ENUM è dichiarata consenti NULL, il valore NULL è un valore legale per la colonna e il valore predefinito è NULL. ") Credo che si possa inserire correttamente NULL in questa colonna. –