MySQL Forums
Forum List  »  General

Re: ENUM column type storage requirements
Posted by: Harrison Fisk
Date: October 14, 2004 10:23AM

Hi,

As far as space, an ENUM (with less than 255 values) and a TINYINT are the same on a per row basis. Each of them takes up a single byte. The ENUM stores the actual text strings in the .frm file, which contains all of the metadata about the table, so it technically does have slightly more overhead by a few bytes.

The choice of which to use, an ENUM or a join table, should depend mostly on your application. If the values listed need to change then you shouldn't use an ENUM. If more than one table has the relationship, then you shouldn't use an ENUM. However if you have a static, couple of choice items, then ENUM can be good for ease of use and as you have said, making things easier to read.

One last thing I want to mention, is that technically there is a way to have a boolean in a single bit, however it isn't very pretty. If you create a column as a CHAR(0) NULL, you could use NULL as false and '' as true. Again, not very pretty, and I wouldn't recommend using that unless you have a real good reason.

Options: ReplyQuote


Subject
Written By
Posted
Re: ENUM column type storage requirements
October 14, 2004 10:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.