Question

--Rev19
ALTER TABLE `staff` MODIFY `role` enum('admin', 'employee', 'guest'); 
ALTER TABLE `staff` ALTER `role` SET DEFAULT 'guest';

It says:

#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 '--Rev19
ALTER TABLE `staff` MODIFY `role` enum('admin', 'employee', 'guest')' at line 1 

Whats wrong here? On a side note, why does SQL error reporting have to be so bad, most languages tell you the specific syntax error where SQL just says, check the manual.

Était-ce utile?

La solution

From the manual:

From a “-- ” sequence to the end of the line. In MySQL, the “-- ” (double-dash) comment style requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on).

So just add a whitespace after -- and you will be fine.

Autres conseils

You need a whitespace after the dashes when using double dash comments.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top