The methods for commenting on SQL statements and database objects are different.
Comments on SQL statements
For general SQL statements, OceanBase Database supports the following three methods for commenting:
From
#to the end of the line, you can comment on one line.From
--to the end of the line, you can comment on one line.From
/*to*/, you can comment on multiple lines.Note
SQL statements do not support nested comments.
In particular, OceanBase Database supports treating the statements within /*! */ as SQL statements and executing the comments. If there is a syntax error within /*! */, the database will treat it as a regular comment.
The format of a comment is as follows:
/*![continuous numeric characters representing the version number]<space><any SQL statement >*/
Example 1: Create a hash partitioned table named
t1with 8 partitions.obclient> CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT) /*!50100 PARTITION BY HASH(c1) PARTITIONS 8*/; Query OK, 0 rows affectedExample 2: Use
ENABLE KEYSto update non-unique indexes. When performing bulk inserts, you can useDISABLE KEYSto temporarily skip index updates and update the indexes after all data has been inserted.obclient> /*!ALTER TABLE t1 DISABLE KEYS */; Query OK, 0 rows affected obclient> /*!ALTER TABLE t1 ENABLE KEYS */; Query OK, 0 rows affectedExample 3: Supports the
DROP IF EXISTSsyntax in PL.obclient> /*!50003 DROP PROCEDURE IF EXISTS */; Query OK, 0 rows affected
Comments on database objects
In DDL statements, you can use the COMMENT clause to specify comments for database objects. Here is an example:
obclient> CREATE TABLE tbl1(pk INT PRIMARY KEY COMMENT 'Primary key');
Query OK, 0 rows affected