For example, suppose I have a TINYINT column that I want to change into an ENUM. Is it possible to write a MySQL query that changes the datatype of the column while mapping the existing data so that (for example) 0 becomes No, 1 becomes Yes, and 2 becomes Maybe?
views:
22answers:
2
                +1 
                A: 
                
                
              
            create the new column next to the old column, use an update to move the data over, then delete the original column.
                  SorcyCat
                   2010-08-23 13:22:20
                
              
                +2 
                A: 
                
                
              I'm not sure if this is possible in MySQL, but an alternative solution would be to:
- Add the new column with the new type with a new name
- Set the new column values (given the old column values)
- Drop the old column
- Rename the new column to have the same name as the old column
                  stark
                   2010-08-23 13:23:10
                
              Alright. I was kinda hoping for some beefy complex super-query, but this should do the trick. :)
                  DLH
                   2010-08-23 13:52:00
                If in doubt, do it the simple way :-)
                  stark
                   2010-08-23 13:56:51