Adding new enum column to an existing table

max85 picture max85 · May 9, 2015 · Viewed 34.9k times · Source

I'm trying to add a gender column to my table with this query:

ALTER TABLE QRCodeUser ADD gender CHAR(1) enum('M','F') NOT NULL;

I get this error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'enum('M','F') NOT NULL' at line 1

What's my mistake?

Answer

dsharew picture dsharew · May 9, 2015

Try this (you dont need to specify the size, char(1) ) :

ALTER TABLE QRCodeUser ADD gender  enum('M','F') NOT NULL;