Enum Type

Help
MattWilby
2014-05-03
2014-06-15
  • MattWilby
    MattWilby
    2014-05-03

    Hi, Im using adminer and trying to create a table where one field uses the enum type but it keep rejecting it. How/where do I set what the possible options are?

    currently SQL command example of what I am trying to add

    ALTER TABLE Players
    ADD Team enum NOT NULL DEFAULT ''U12s','U13s'' AFTER Firstname,
    COMMENT=''; -- 0.000 s

     
  • Paul
    Paul
    2014-05-04

    I don't personally care for enums because of other troubles that they cause, but know this: http://komlenic.com/244/8-reasons-why-mysqls-enum-data-type-is-evil/

    Anyway, the syntax of what you have is not quite correct, but try this instead:

    ALTER TABLE Players ADD Team enum ('U12s','U13s') NOT NULL default 'U12s'  AFTER Firstname, COMMENT=''
    



    See the attached images. One shows the alter query run, the other shows the table afterwards.

     
    Last edit: Paul 2014-05-04
  • Jakub Vrána
    Jakub Vrána
    2014-06-15

    MattWilby, it seems like you specified the possible enum values in Default value. It has to be specified in Length.