I want to sort in various ways, and would like to see examples of ENUM at work. Anyone with there finger on good examples, please point me that way, thanks.
JW.
Justin
03-12-2000, 03:34 PM
</font><font face="Courier" size="3">mysql> create table computers (
[nbsp][nbsp][nbsp][nbsp]-> ID int default 0 not null auto_increment,
[nbsp][nbsp][nbsp][nbsp]-> OS enum ('Win95', 'Win98', 'Win2k', 'NT4', 'Linux'),
[nbsp][nbsp][nbsp][nbsp]-> CPU enum ('PII', 'PIII', 'K6', 'Athlon'),
[nbsp][nbsp][nbsp][nbsp]-> case_type enum ('Desktop', 'Mini Tower', 'Mid Tower', 'Full Tower'),
[nbsp][nbsp][nbsp][nbsp]-> form_factor enum ('AT', 'ATX'),
[nbsp][nbsp][nbsp][nbsp]-> power_supply enum ('150W', '200W', '250W', '300W'),
[nbsp][nbsp][nbsp][nbsp]-> primary key(ID));
</font><font face="Verdana, Arial" size="2">
Enums can be useful for things like that - the above is just an example table, showing possible uses for enum.
Advantages:
Enum uses only one byte, and is extremely fast compared to using a varchar field and doing string compares - because it uses only one byte, it is simply a quick binary comparison.
Disadvantages:
Slightly more difficult to add more fields, and if you have too many, makes it hard to read the table description on the screen (as it will go too wide and word wrap).
Hope this helps :)
------------------
Justin Nelson
FutureQuest (http://www.FutureQuest.net/index.php) Support
Yah, like, fer-sure. That helps.
Just starting into MySQL and the DBI.[nbsp][nbsp]I have the table and sorting done under Perl, but sl-o-o-w to sort the database and various combos with hashes, and it isn't even that large at this point, sorting wages and job categories, with sub selects (oops wrong term for this version of MySQL).
Thanks
JW.
vBulletin® v3.6.8, Copyright ©2000-2009, Jelsoft Enterprises Ltd.