MySQL ENUM VARCHAR as an alternative

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Let's say we have

type ENUM('fish','mammal','bird')

An alternative is

type VARCHAR(20)  COMENT "fish, bird, etc"

This is quite open-ended in that new types are trivially added.

Comparison, and whether better or worse than ENUM:

  • (same) INSERT: simply provide the string
  • (worse?) On INSERT a typo will go unnoticed
  • (same) SELECT: the actual string is returned
  • (worse) A lot more space is consumed


Got any MySQL Question?