문제

--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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top