I have a MySQL database which currently uses a tinyint field to store the type of record. It uses an odd numbering, and we are in the process to change this. So currently, it reads:
record type
1 60
2 62
3 60
4 61
5 63
The numbers represent the type, with:
60 = car
61 = bike
62 = motorcycle
We need to transform this into an enum field, using the values car, bike, motorcycle. However, the table in question in being used from a very large number of pages, where SELECTs and INSERTs are being made using the original numbers. That will change gradually. So I was wondering: is there a way to change the indexes of the enum field, so that I could change the field to enum and still save a new record with type = 60, and this becomes ‘car’? I know there is a way to set it to 0 and it will become car, but clearly that requires us to change all of the pages and there is no time for this…
Unfortunately this is not possible. The manual itself leaves no room for hope:
Seeing as there’s nothing you can do about that, I have to ask: why do you need to make this an
enum? I have yet to come across a situation where anenumprovided any benefit apart convenience to programmers who look at query results by eye. What is the benefit you are looking to gain? I am no guru, but IMHO no matter what you want to achieve there is another (better) way than using anenum.