I just realized that there are lines in the sql files (.sql
) which start with /*!
and are NOT comments and they are executed to do some system level tasks.
I want to know what the lines starting with /*!
really mean for MySQL and why use that number beside the symbols (4000 in my example).
Here is the example:
/*!40000 ALTER TABLE `my_table` DISABLE KEYS */;
INSERT INTO my_table VALUES ('value1','value2');
/*!40000 ALTER TABLE `my_table` ENABLE KEYS */;
Edit: I don't think this question is a duplicate as per the linked question. This question is about how MySQL treats it. It didn't ask how to remove these comments and the question doesn't see it as a comment for MySQL.
Those lines are treated as comments by any RDBMS other that MySQL. MySQL however will execute them.
This enables MySQL specific keywords or syntax inside the SQL file without breaking it for other systems.
The number represents the version you are targeting, e.g. /*!32302 TEMPORARY */
will only be executed by MySQL version 3.23.02 or higher.
Have a look at the docs for more info:
MySQL Server supports some variants of C-style comments. These enable you to write code that includes MySQL extensions, but is still portable, by using comments of the following form:
/*! MySQL-specific code */
In this case, MySQL Server parses and executes the code within the comment as it would any other SQL statement, but other SQL servers will ignore the extensions. For example, MySQL Server recognizes the STRAIGHT_JOIN keyword in the following statement, but other servers will not:
SELECT /*! STRAIGHT_JOIN */ col1 FROM table1,table2 WHERE ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With