SQL statements and database objects use different methods for commenting.
Comment on SQL statements
For regular SQL statements, OceanBase AI Database supports the following three comment methods:
A line starting with
#is a comment.Any line starting with
--is a comment.Multiple lines can be commented out from
/*to*/.Note
SQL statements do not support nested comments.
Specifically, OceanBase AI Database supports treating the statements inside /*!*/ as SQL and executing them. If a syntax error occurs within /*!*/, the database treats it as a comment by default.
The format of the comments is as follows:
/*![Consecutive numeric characters representing the version number]<space><Any SQL statement >*/
Example 1: Creates a hash partition for table
t1with8partitions.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 batch inserts, you can useDISABLE KEYSto avoid updates initially, and then update the indexes after all inserts are complete.obclient> /*!ALTER TABLE t1 DISABLE KEYS */; Query OK, 0 rows affected obclient> /*!ALTER TABLE t1 ENABLE KEYS */; Query OK, 0 rows affectedExample 3: Supports executing the
DROP IF EXISTSsyntax of PL.obclient> /*!50003 DROP PROCEDURE IF EXISTS */; Query OK, 0 rows affected
Comments on database objects
You can use the COMMENT clause in a DDL statement to specify comments for database objects. Example:
obclient> CREATE TABLE tbl1(pk INT PRIMARY KEY COMMENT 'Primary key');
Query OK, 0 rows affected