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?

1

2 Answers

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;

    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)

NO is a reserved word in ANSI SQL, but currently it is not used as a keyword in MySQL. It is already defined as such, so in later extensions a semantic usage could be added.

It is a common practice in language definition, that some words are reserved, but not used, because they are not needed at the early state of the language and maybe even later on there is no requirement to make use of it.
But it always is a pain to add reserved keywords later on into an existing language, as you might have variables with that name in existing scripts and you would need to update/rewrite them to be compatible to the language update (which language updates try to prevent to be backwards compatible and simplify the update process). That's why the language designers start with reserving more keywords as required, to be later on more flexible to add them into the language without breaking backwards compatibility.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like