Search code examples
mysqlenumsalter

Adding new enum column to an existing table


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?


Solution

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

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