How can I get rid of these comments in a MySQL dump?(如何在 MySQL 转储中删除这些注释?)
问题描述
我正在尝试创建一个简单的结构,仅转储我的数据库.使用 mysqldump 给我一个结果:
I'm trying to create a simple structure only dump of my database. Using mysqldump gives me a result like:
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `foo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
无论我怎么努力,我似乎都无法摆脱那些评论.
No matter what I try, I just can't seem to get rid of those comments.
我目前正在使用:mysqldump -p -d --add-drop-table --skip-tz-utc --skip-set-charset -h 127.0.0.1 -u foo bar --result-file=dumpfile.sql
但是我确实希望保留其他注释,例如 -- MySQL dump 10.13 Distrib 5.1.41, for Win32 (ia32)
I do however wish to retain other comments, such as -- MySQL dump 10.13 Distrib 5.1.41, for Win32 (ia32)
推荐答案
哇!即使它们看起来那样,这些也不是真正的评论.它们是条件执行令牌.
WHOA! These aren't really comments even though they look that way. They are conditional-execution tokens.
走这条线:
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
如果 mySQL 的版本是 4.00.14 或更高,那么 MySQL 服务器将运行此语句.
If the version of mySQL is 4.00.14 or higher, then the MySQL server will run this statement.
这个神奇的注释语法记录在注释语法 手册部分.
This magic comment syntax is documented in the Comment Syntax section of the manual.
你可能不想摆脱这些东西.
You probably don't want to get rid of this stuff.
这篇关于如何在 MySQL 转储中删除这些注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 MySQL 转储中删除这些注释?
基础教程推荐
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
