From: Martijn Tonies Date: January 5 2004 1:44pm Subject: Re: Enum default values List-Archive: http://lists.mysql.com/mysql/156835 Message-Id: <05c301c3d392$022faa30$0e02a8c0@martijn> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit > [snip] > Yes, the DEFAULT doesn't apply. However, shouldn't MySQL > raise an exception because '' isn't a valid value for this ENUM > specification? > [/snip] > > >From http://www.mysql.com/doc/en/ENUM.html > > The value may also be the empty string ("") or NULL under certain > circumstances: > > If you insert an invalid value into an ENUM (that is, a string not > present in the list of allowed values), the empty string is inserted > instead as a special error value. This string can be distinguished from > a 'normal' empty string by the fact that this string has the numerical > value 0. More about this later. > If an ENUM is declared NULL, NULL is also a legal value for the column, > and the default value is NULL. If an ENUM is declared NOT NULL, the > default value is the first element of the list of allowed values. ok, but the table was defined as: create table property ( property_id int(10) unsigned NOT NULL auto_increment, name char(30) default NULL, changeday enum('Sun','Mon','Tue','Wed','Thu','Fri','Sat') not null default 'Sat', PRIMARY KEY (property_id) ); "changeday" is NOT NULL -> but you still can enter '' ... Strange and, IMO, a bug. What's the use of restricting to a set of possible values without enforcing it? With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com