Comment Syntax; Mysql; Comments - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

• By default,
or from 5.0.2 on with
precedence.
See
Section 5.1.7, "Server SQL

9.6. Comment Syntax

MySQL Server supports three comment styles:
• From a "#" character to the end of the line.
• From a
"--
requires the second dash to be followed by at least one whitespace or control character (such as a
space, tab, newline, and so on). This syntax differs slightly from standard SQL comment syntax, as
discussed in
• From a
/*
enables a comment to extend over multiple lines because the beginning and closing sequences need
not be on the same line.
The following example demonstrates all three comment styles:
mysql>
SELECT 1+1;
mysql>
SELECT 1+1;
mysql>
SELECT 1 /* this is an in-line comment */ + 1;
mysql>
SELECT 1+
/*
this is a
multiple-line comment
*/
1;
Nested comments are not supported.
MySQL Server supports some variants of C-style comments. These enable you to write code that
includes MySQL extensions, but is still portable, by using comments of the following form:
/*!
MySQL-specific code
In this case, MySQL Server parses and executes the code within the comment as it would any other
SQL statement, but other SQL servers will ignore the extensions. For example, MySQL Server
recognizes the
SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...
If you add a version number after the "!" character, the syntax within the comment is executed only if
the MySQL version is greater than or equal to the specified version number. The
in the following comment is executed only by servers from MySQL 3.23.02 or higher:
CREATE /*!32302 TEMPORARY */ TABLE t (a INT);
The comment syntax just described applies to how the
client program also performs some parsing of statements before sending them to the server. (It

mysql

does this to determine statement boundaries within a multiple-statement input line.)
Comments in this format,
comment stored routines, the comments will not be retained on the server.
The use of short-form
supported.
[880]
has a higher precedence than
!
HIGH_NOT_PRECEDENCE
Modes".
" sequence to the end of the line. In MySQL, the
Section 1.8.5.5, "'--' as the Start of a
sequence to the following
# This comment continues to the end of line
-- This comment continues to the end of line
*/
keyword in the following statement, but other servers will not:
STRAIGHT_JOIN
/*!12345 ...
commands such as
mysql
Comment Syntax
as of MySQL 5.0.2. For earlier versions,
NOT
[536]
enabled,
Comment".
sequence, as in the C programming language. This syntax
*/
mysqld
*/, are not stored on the server. If this format is used to
within multi-line
\C
766
[880]
and
have the same
!
NOT
"--
" (double-dash) comment style
TEMPORARY
server parses SQL statements. The
comments is not
/* ... */
keyword

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 5.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Mysql 5.0

Table of Contents