Search code examples
mysqlreserved-words

What is the "no" keyword used for in MySQL?


I just randomly found out that "no" is a reserved word/keyword in Mysql.

I searched on Google what is it used for, but couldn't find an answer.

Can someone explain or is there any link to article that explains each Mysql's reserved keyword usage?

https://dev.mysql.com/doc/refman/8.0/en/keywords.html


Solution

  • I searched the MySQL 8.0 grammar file, and found the NO token used in the following ways:

    • In cascading foreign key declaration, you can use ON {UPDATE|DELETE} NO ACTION.

    • In the NO SQL characteristic for stored routines.

    • An option to the COMMIT statement, which means do not automatically start a new transaction or release the session after committing the current transaction.

      COMMIT AND NO CHAIN;
      COMMIT AND NO RELEASE;
      

      https://dev.mysql.com/doc/refman/8.0/en/commit.html says:

      Including the NO keyword suppresses CHAIN or RELEASE completion, which can be useful if the completion_type system variable is set to cause chaining or release completion by default.

    • As a merge insert type, which is a table option when using CREATE TABLE for a MERGE table. Inserts are disabled if you declare a table as:

      CREATE TABLE mytable (...) ENGINE=MERGE UNION=(...) INSERT_METHOD=NO;
      

    For what it's worth, the NO keyword is not a reserved keyword. In the keywords documentation page you linked to, reserved keywords are noted with "(R)" but NO doesn't have that note. Therefore you can use NO as an identifier without necessarily delimiting it in back-ticks.

    mysql> create table no ( i int);
    Query OK, 0 rows affected (0.05 sec)