MySQL: enum or char(1)? Oct12 '04
In a recent table creation, in MySQL, I ran into a situation that could go one of two ways.
The field I want to create will only contain a single letter. That letter is simply any letter of the alphabet. There are 26 letters total, and only one is chosen to be stored in that field.
In MySQL, which column type should be used?
An enum column type, with an option for each letter of the alphabet?
enum('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p',
'q','r','s','t','u','v','w','x','y','z');
Or... a char column type, with a character limit of 1?
char(1);
What do you think?
Categories: SQL ![]()
Add Feedback (view all)
Leave feedback
Thanks for the link and feedback. You're right, though. It's barely worth consideration. It's not going to affect anything drastically. Ther ... Read more.
Because I'm lazy, and can't be bothered looking it up, is enum case sensitive, or could you have got away with using the column type you specified ... Read more.
Josh, enum is NOT case sensitive. But you bring up a good point. I will have to look into that. ... Read more.
Actually, enum can be case sensitive. When retrieved, values stored into an ENUM column are displayed usi ... Read more.
Nice blockquote style! ... Read more.
Haha this is pretty late feedback. CHAR can be any character. Which include numbers, etc... ... Read more.
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
- ‘Paste Special’ for headache relief
- Flu shot: you in or out?
- Social networking: say it; don't spray it
Similar Entries
- Install Apache, PHP, MySQL on Windows (221 recent visits)
- MySQL search criteria - column alias (1345 recent visits)
- MySQL integer columns and display width (1320 recent visits)
- MySQL LEFT JOIN syntax (3464 recent visits)
- MySQL viewing saved searches (30 recent visits)
- MySQL changing column types (893 recent visits)
Stats
554 unique visits since August 2008
You should read this (if you haven't already), mainly the comments. http://dev.mysql.com/doc/mysql/en/ENUM.html enum column type allo ... Read more.