Hi Monty,

I've been experimenting with ENUM NOT NULL columns without a default
value. The documentation (section 6.5.3 again) states:

"If no DEFAULT value is specified for a column, MySQL automatically
assigns one. If the column may take NULL as a value, the default value is
NULL. If the column is declared as NOT NULL, the default value depends on
the column type ... for ENUM, the default is the first enumeration value."

This is all fine (and seems like a reasonable assumption to make), but I
discovered that using ALTER TABLE on the column to DROP DEFAULT does
nothing - but that SET DEFAULT '' does remove it.

Would it be possible to make DROP DEFAULT set the default to '' on an
ENUM NOT NULL column?

Here's an example of what I'm talking about:

mysql> CREATE TABLE test_enum (e ENUM('a','b','c') NOT NULL);
mysql> DESCRIBE test_enum;
+-------+-------------------+------+-----+---------+-------+
| Field | Type              | Null | Key | Default | Extra |
+-------+-------------------+------+-----+---------+-------+
| e     | enum('a','b','c') |      |     | a       |       |
+-------+-------------------+------+-----+---------+-------+

mysql> ALTER TABLE test_enum ALTER COLUMN e DROP DEFAULT;
mysql> DESCRIBE test_enum;
+-------+-------------------+------+-----+---------+-------+
| Field | Type              | Null | Key | Default | Extra |
+-------+-------------------+------+-----+---------+-------+
| e     | enum('a','b','c') |      |     | a       |       |
+-------+-------------------+------+-----+---------+-------+

mysql> ALTER TABLE test_enum ALTER COLUMN e SET DEFAULT '';
mysql> DESCRIBE test_enum;
+-------+-------------------+------+-----+---------+-------+
| Field | Type              | Null | Key | Default | Extra |
+-------+-------------------+------+-----+---------+-------+
| e     | enum('a','b','c') |      |     |         |       |
+-------+-------------------+------+-----+---------+-------+

Thanks,

Corin

/------------------------+-------------------------------------\
| Corin Hartland-Swann   |    Tel: +44 (0) 20 7491 2000        |
| Commerce Internet Ltd  |    Fax: +44 (0) 20 7491 2010        |
| 22 Cavendish Buildings | Mobile: +44 (0) 79 5854 0027        | 
| Gilbert Street         |                                     |
| Mayfair                |    Web: http://www.commerce.uk.net/ |
| London W1K 5HJ         | E-Mail: [EMAIL PROTECTED]        |
\------------------------+-------------------------------------/


---------------------------------------------------------------------
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