Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2016
    Posts
    1

    Unanswered: What is the use of ENUMs in MySQL?

    Hello Everyone,

    Please tell me the usage of ENUMS in MYSQL?
    How it work and benefits of ENUMS?

  2. #2
    Join Date
    Dec 2012
    Posts
    43
    Hello evamaris,

    usage of ENUM in MySQL is:

    Code:
    CREATE TABLE shirts (
        name VARCHAR(40),
        size ENUM('x-small', 'small', 'medium', 'large', 'x-large')
    );
    INSERT INTO shirts (name, size) VALUES ('dress shirt','large'), ('t-shirt','medium'),
      ('polo shirt','small');
    SELECT name, size FROM shirts WHERE size = 'medium';
    +---------+--------+
    | name    | size   |
    +---------+--------+
    | t-shirt | medium |
    +---------+--------+
    UPDATE shirts SET size = 'small' WHERE size = 'large';
    COMMIT;
    You can find complete documentation about ENUM at
    http://dev.mysql.com/doc/refman/5.7/en/enum.html

    But in most cases you won't use ENUMs. Why?
    Please read the very good article about "why mysqls enum data type is evil":
    http://komlenic.com/244/8-reasons-wh...a-type-is-evil

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •