DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(mysql.info.gz) Comments

Info Catalog (mysql.info.gz) System Variables (mysql.info.gz) Language Structure (mysql.info.gz) Reserved words
 
 9.5 Comment Syntax
 ==================
 
 The MySQL server supports three comment styles:
 
    * From a `#' character to the end of the line.
 
    * From a `-- ' sequence to the end of the line.  This style is
      supported as of MySQL 3.23.3.  Note that the `-- ' (double-dash)
      comment style requires the second dash to be followed by at least
      one space (or by a control character such as a newline). This
      syntax differs slightly from standard SQL comment syntax, as
      discussed in  ANSI diff comments.
 
    * From a `/*' sequence to the following `*/' sequence.  The closing
      sequence need not be on the same line, so this syntax allows a
      comment to extend over multiple lines.
 
 
 The following example demonstrates all three comment styles:
 
      mysql> SELECT 1+1;     # This comment continues to the end of line
      mysql> SELECT 1+1;     -- This comment continues to the end of line
      mysql> SELECT 1 /* this is an in-line comment */ + 1;
      mysql> SELECT 1+
      /*
      this is a
      multiple-line comment
      */
      1;
 
 The comment syntax just described applies to how the `mysqld' server
 parses SQL statements. The `mysql' client program also performs some
 parsing of statements before sending them to the server. (For example,
 it does this to determine statement boundaries within a
 multiple-statement input line.) However, there are some limitations on
 the way that `mysql' parses `/* ... */' comments:
 
    * A semicolon within the comment is taken to indicate the end of the
      current SQL statement and anything following it to indicate the
      beginning of the next statement.  This problem was fixed in MySQL
      4.0.13.
 
    * A single quote, double quote, or backtick character is taken to
      indicate the beginning of a quoted string or identifier, even
      within a comment.  If the quote is not matched by a second quote
      within the comment, the parser doesn't realize the comment has
      ended.  If you are running `mysql' interactively, you can tell
      that it has gotten confused like this because the prompt changes
      from `mysql>' to `'>', `">', or ``>'.  This problem was fixed in
      MySQL 4.1.1.
 
    * An exclamation point used with this style of comment delimiter
      (such as `/*! ... */') marks portions of SQL statements for
      conditional execution. For more information and examples, see
       Extensions to ANSI.
 
 
 For affected versions of MySQL, these limitations apply both when you
 run `mysql' interactively and when you put commands in a file and use
 `mysql' in batch mode to process the file with `mysql < FILE_NAME'.
 
Info Catalog (mysql.info.gz) System Variables (mysql.info.gz) Language Structure (mysql.info.gz) Reserved words
automatically generated byinfo2html