Home > Database > Mysql Tutorial > How Can I Remove Annoying MySQL Dump Comments Without Losing Useful Ones?

How Can I Remove Annoying MySQL Dump Comments Without Losing Useful Ones?

Susan Sarandon
Release: 2024-12-02 19:36:11
Original
502 people have browsed it

How Can I Remove Annoying MySQL Dump Comments Without Losing Useful Ones?

Getting Rid of MySQL Dump Comments

When attempting to dump a database solely containing its structure, you might encounter persistent comments resembling:

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
Copy after login

Despite various attempts, these comments refuse to disappear. This issue arises from a misunderstanding of their true nature.

Conditional-Execution Tokens: Not Your Average Comments

Contrary to their appearance, these "comments" are not actually comments. Instead, they serve as conditional-execution tokens. Their syntax, as documented in MySQL's Comment Syntax section, follows this logic: if the MySQL version number is equal to or greater than the specified version, the MySQL server will execute the subsequent statement.

For example:

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
Copy after login

If the MySQL version is 4.00.14 or higher, this statement will be executed by the MySQL server.

Retaining Useful Comments

While removing these conditional-execution tokens may seem desirable, it's crucial to preserve other valuable comments for reference, such as:

-- MySQL dump 10.13  Distrib 5.1.41, for Win32 (ia32)
Copy after login

The above is the detailed content of How Can I Remove Annoying MySQL Dump Comments Without Losing Useful Ones?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template