如何在 MySQL 转储中删除这些注释? [英] How can I get rid of these comments in a MySQL dump?

查看:46
本文介绍了如何在 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 转储中删除这些注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆