Bill Noble
Bill Noble

Reputation: 6734

What happens if you add an element to an existing MySQL set?

I have an existing MySQL database with a set type defined as: ('blue', 'orange', 'purple').

I have been asked to add 'green' to the set and want the set to be ('blue', 'green', 'orange', 'purple'), i.e. in alphabetic order.

What impact, if any, will this have on the existing database records? I think I read somewhere that the set value is stored as an offset into the set so if I insert 'green' in the way shown above will this cause records with fields set to 'orange' to point to the wrong set member? Or does everything magically sort itself out?

Upvotes: 0

Views: 65

Answers (1)

Jim
Jim

Reputation: 19582

It will rebuild the whole table which is something that you might want to avoid. If you add the enum to the end the table will be unaffected.

Upvotes: 1

Related Questions