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

1
  • 1
    It's not "SQL error reporting" that's bad, it's MySQL's error reporting that is "bad". Other DBMS are much clearer with their syntax error messages. Commented Jul 15, 2013 at 16:44

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.