OderWat
OderWat

Reputation: 5709

Why does MySQL allow duplicate values in enum declarations

I just stumbled over the fact that MySQL allows duplicate enum values.

Like in en enum('a','a','b','c') NOT NULL)

Why?

Upvotes: 0

Views: 2970

Answers (1)

Kylie
Kylie

Reputation: 11749

Its because the way MYSQL actually handles ENUM is by INDEX.

So to MYSQL....

 ('a','a','b','c')

Actually equals

 (0,1,2,3)

See ENUM explanation here

And some reasons why to avoid it...if possible, specially if using it as a reference field

Avoid ENUM

Upvotes: 2

Related Questions