List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:August 5 1999 9:47am
Subject:altering ENUM columns
View as plain text  
>>>>> "Richard" == Richard Antecki
> <rantecki@stripped> writes:

Richard> Hi,

Richard> I know one can add items to an ENUM safely, but is it safe to completely
Richard> change the elements in an ENUM.

Richard> For example, if I have an ENUM defined as:

Richard>
> enum('ACTIVE','EXPIRED','OVER_LIMIT','OVER_BALANCE','FROZEN','CLOSED','INVALID','ONHOLD')

Richard> I now realise that I don't really need OVER_LIMIT or OVER_BALANCE, so if I
Richard> alter the enum to be:

Richard> enum('ACTIVE','EXPIRED','FROZEN','CLOSED','INVALID','ONHOLD')

Richard> What happens to the columns set as FROZEN, CLOSED ... and what happens to
Richard> columns already set as OVER_LIMIT, OVER_BALANCE?

Richard> I guess this depends on the internal representation.  If they are stored
Richard> internally as integers then any alterations like this will cause values to
Richard> change, am I correct?

Richard> Thanks,

Richard> Richard

Hi!

If you do an ALTER TABLE on an enum that changes, then MySQL converts
the enum to a string and then back to the new enum.  This means that
all OVER_LIMIT and OVER_BALANCE items are simply set to 0 (= wrong
enum value)

Regards,
Monty
Thread
Colum NamesTom Bell5 Aug
  • Re: Colum NamesPaul DuBois5 Aug
  • Re: Colum NamesRalph Graulich5 Aug
    • altering ENUM columnsRichard Antecki5 Aug
      • altering ENUM columnsMichael Widenius5 Aug