I have these lines at the top of a MySQL .sql file (dumped with phpMyAdmin):
我将这些行放在MySQL .sql文件的顶部(使用phpMyAdmin转储):
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
But they all seem to be commented out. So will MySQL ignore them when the file is loaded back into a database? If so, why generate these lines at all?
但他们似乎都被评论出来了。那么,当文件被加载回数据库时,MySQL会忽略它们吗?如果是这样,为什么要产生这些线?
2 个解决方案
#1
29
These are conditional comments aimed at certain versions of mySQL.
这些是针对某些版本的mySQL的条件评论。
从这里到这里:
- MySQL version specific comments start with
/*!
- MySQL版本的具体注释以/ *开头!
- And end with
*/
- 以* /结束
- Version numbers are always 5 digits
- 版本号始终为5位数
- Version numbers are in the format major release number, minor release number, revision number with the major being 1 digit and the minor and revision being 2 digits left-padded with 0’s
- 版本号的格式为主要版本号,次要版本号,版本号,主要版本为1位,次要版本为2位数,左侧填充0位
- Version specific comments will target any version equal to or higher than the version number listed
- 特定于版本的注释将针对等于或高于列出的版本号的任何版本
#2
6
MySQL will parse and execute these lines of code, I believe for localization and character-encoding stuff, because the comments start with /*!
(with the exclamation mark) instead of just the C-style /*
.
MySQL将解析并执行这些代码行,我相信本地化和字符编码的东西,因为注释以/ *开头! (带感叹号)而不仅仅是C风格/ *。
Think of it the same way you do conditional comments and Internet Explorer. <!--[if IE]><![endif]-->
looks like any plain old HTML comment to other browsers, but IE recognizes this special comment and parses it as needed. Likewise, /*! */
looks like any other comment to other SQL DBMSes but is special to MySQL.
可以像使用条件注释和Internet Explorer一样考虑它。 <! - [if IE]> <![endif] - >看起来像是对其他浏览器的任何普通的旧HTML评论,但IE会识别此特殊注释并根据需要对其进行解析。同样,/ *! * /看起来像对其他SQL DBMS的任何其他注释,但对MySQL来说是特殊的。
#1
29
These are conditional comments aimed at certain versions of mySQL.
这些是针对某些版本的mySQL的条件评论。
从这里到这里:
- MySQL version specific comments start with
/*!
- MySQL版本的具体注释以/ *开头!
- And end with
*/
- 以* /结束
- Version numbers are always 5 digits
- 版本号始终为5位数
- Version numbers are in the format major release number, minor release number, revision number with the major being 1 digit and the minor and revision being 2 digits left-padded with 0’s
- 版本号的格式为主要版本号,次要版本号,版本号,主要版本为1位,次要版本为2位数,左侧填充0位
- Version specific comments will target any version equal to or higher than the version number listed
- 特定于版本的注释将针对等于或高于列出的版本号的任何版本
#2
6
MySQL will parse and execute these lines of code, I believe for localization and character-encoding stuff, because the comments start with /*!
(with the exclamation mark) instead of just the C-style /*
.
MySQL将解析并执行这些代码行,我相信本地化和字符编码的东西,因为注释以/ *开头! (带感叹号)而不仅仅是C风格/ *。
Think of it the same way you do conditional comments and Internet Explorer. <!--[if IE]><![endif]-->
looks like any plain old HTML comment to other browsers, but IE recognizes this special comment and parses it as needed. Likewise, /*! */
looks like any other comment to other SQL DBMSes but is special to MySQL.
可以像使用条件注释和Internet Explorer一样考虑它。 <! - [if IE]> <![endif] - >看起来像是对其他浏览器的任何普通的旧HTML评论,但IE会识别此特殊注释并根据需要对其进行解析。同样,/ *! * /看起来像对其他SQL DBMS的任何其他注释,但对MySQL来说是特殊的。