Mysql Error 1064 ("You have an error in your SQL syntax") triggered by SQL comments -
i have series of scripts creating schema, comment following before each instruction:
-------------------------------------------------------- -- table table_name --------------------------------------------------------
when execute script mysql on command line, bunch of errors following:
error 1064 (42000): have error in sql syntax; check manual corresponds mysql server version right syntax use near '------------------------------------------------------ ------------------------' @ line 1
(actually, 1 error each comment, in spite of message referring line 1).
to solve problem removed comments , script ran without problems, surprised see such behaviour , unable find relevant question here on stackoverflow. have explanation? did ever observe such odd behaviour?
i running mysql 5.6.30, default 5.6 on ubuntu @ time.
from mysql manual:
from “-- ” sequence end of line. in mysql, “-- ” (double-dash) comment style requires second dash followed by at least 1 whitespace or control character (such space, tab, newline, , on). syntax differs standard sql comment syntax, discussed in section 1.8.2.4, “'--' start of comment”.
(emphasis mine)
tl;dr --
indicating comment must followed @ least 1 whitespace or control character.
fixed code of yours:
-- ----------------------------------------------------- -- table table_name -- -----------------------------------------------------
in mysql can use syntax:
/* * table table_name */
or this:
# ----------------------------------------------------- # table table_name # -----------------------------------------------------
Comments
Post a Comment