db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernt M. Johnsen" <Bernt.John...@Sun.COM>
Subject Re: ENUM
Date Fri, 08 Sep 2006 13:25:39 GMT
Dan Scott wrote:
> On the SET datatype: Even the MySQL docs include a section upfront
> called "Why you shouldn't use SET"
> (http://dev.mysql.com/tech-resources/articles/mysql-set-datatype.html).
> It's not an atomic datatype. Bad.
>
> On ENUM: The SQL standard way of doing the equivalent of ENUM, and
> therefore the Derby way, is to define a check constraint on the
> column.
>
> For example, in MySQL you might do something like:
>
> CREATE TABLE nonstandard (
>  sizes ENUM('small', 'medium', 'large')
> );
>
> Implementing this as a check constraint in Derby, on the other hand,
> would look something like:
>
> CREATE TABLE standard (
>  sizes VARCHAR(32) CONSTRAINT sizes_ck CHECK (sizes IN ('small',
> 'medium', 'large'))
> );

The CHECK constraint is implemented in Derby, and is a portable
standard way of doing this. The MySQL enum is neeither standard nor
portable.

-- 
Bernt Marius Johnsen, Database Technology Group,
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Mime
View raw message