Comments within SQL statements and database objects are specified in different ways.
Comments within SQL statements
OceanBase Database allows you to add comments in general SQL statements by using one of the following three methods:
Start the comment with a number sign (
#) and end it with a line break. The comment text cannot extend to a new line.Start the comment with two hyphens (
--) and end it with a line break. The comment text cannot extend to a new line.Start the comment with a slash and an asterisk (
/*) and end it with an asterisk and a slash (*/). The comment text can span multiple lines.
SQL statements do not support nested comments.
OceanBase Database executes statements in comments. Example:
SELECT /*! STRAIGHT_JOIN */ c1 FROM t1 WHERE...
Note
MySQL supports a special comment in the following format:
/*! MySQL-specific code */. This comment is not treated as a comment in OceanBase Database.
Comments for database objects
You can use a COMMENT clause in a DDL statement to specify comments for a database object. Example:
CREATE TABLE t(pk INT PRIMARY KEY COMMENT 'primary key');