Skip to main content

Comments

The methods for commenting on SQL statements and database objects are different.

Comments on SQL statements

For general SQL statements, seekdb supports the following three methods:

  • From # to the end of the line, you can comment on a line.

  • From -- to the end of the line, you can comment on a line.

  • From /* to */, you can comment on multiple lines.

    info

    SQL statements do not support nested comments.

In addition, seekdb supports treating the statements within /*! as SQL statements and executing the comments. If a syntax error occurs within /*!, the database will treat it as a comment by default.

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 t1 with 8 partitions.

    CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT) /*!50100
    PARTITION BY HASH(c1) PARTITIONS 8*/;
    Query OK, 0 rows affected (0.098 sec)
  • Example 2: Use ENABLE KEYS to update non-unique indexes and DISABLE KEYS to temporarily skip updates during batch inserts. After all indexes are inserted, update the indexes.

    /*!ALTER TABLE t1 DISABLE KEYS */;
    Query OK, 0 rows affected (0.000 sec)

    /*!ALTER TABLE t1 ENABLE KEYS */;
    Query OK, 0 rows affected (0.000 sec)
  • Example 3: Support the DROP IF EXISTS syntax in PL.

    /*!50003 DROP PROCEDURE IF EXISTS */;
    Query OK, 0 rows affected (0.000 sec)

Comments on database objects

In DDL statements, you can specify comments for database objects using the COMMENT clause. Here is an example:

CREATE TABLE tbl1(pk INT PRIMARY KEY COMMENT 'Primary key');
Query OK, 0 rows affected (0.073 sec)