MySQL syntax: What is this?

They are variable assignments. The assignments are wrapped in executable comments in such a way that they are executed when MySQL is used and left alone if some other RDBMS is used. Furthermore, the 40101 indicates that the comments are not to be retained in the database i.e. if the lines are executed, they are only executed when the sql file is executed.


Those special comment always confuse me, after checking the doc https://dev.mysql.com/doc/refman/8.0/en/comments.html

if you add a version number after the ! character, the syntax within the comment is executed only if the MySQL version is greater than or equal to the specified version number. The KEY_BLOCK_SIZE keyword in the following comment is executed only by servers from MySQL 5.1.10 or higher:

CREATE TABLE t1(a INT, KEY (a)) /*!50110 KEY_BLOCK_SIZE=1024 */;

That is not hard to understand. In term of 50110, means 5(major)01(minor)10(revision) = run that in MySQL version >= 5.1.10 or higher


This is variable assignments wrapped within conditional comments. The code is executed depending on the version of MySQL in question, see comments

Tags:

Mysql

Sql