Sample Header Ad - 728x90

MariaDB: change enum

0 votes
1 answer
59 views
I have a MariaDB database. mariadb Ver 15.1 Distrib 10.11.6-MariaDB One of my tabes uses an enum field (generated by Java JPA, not manually). +-----------+-----------------------------------------------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-----------------------------------------------------------------+------+-----+---------+----------------+ | id | bigint(20) | NO | PRI | NULL | auto_increment | | name | varchar(255) | YES | UNI | NULL | | | type | enum('A','B','G','H','Z') | YES | | NULL | | | meta | longtext | YES | | NULL | | +-----------+-----------------------------------------------------------------+------+-----+---------+----------------+ This field is used in records of the table. 1000 | sam | A | abc 1004 | max | Z | 000 1019 | tim | H | a89 Now I need to add another field to the enum - lets say it is of value "C". My question is about the changing of the enum and how it is used internally. I need to keep the existing enum-records unharmed and working.. Can I simple change the enum to a new value of 'A', 'B', 'C', 'G', 'H', 'Z' or do I need to keep the order (maybe it uses numbers internally and a reorder would crash old records?)? 'A', 'B', 'G', 'H', 'Z', 'C' I would alter with ALTER TABLE table_name MODIFY COLUMN column_name enum( 'enum1', 'enum2', ... )
Asked by chris01 (101 rep)
May 19, 2025, 09:38 AM
Last activity: May 19, 2025, 11:29 AM