Stripping Conditional Tokens from MySQL Dumps
In an attempt to generate a simple structure-only dump of a database, the use of mysqldump often returns unexpected results, including conditional-execution tokens that act as comments. These tokens can appear as:
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
While resembling comments, these tokens control execution based on the MySQL version. If the version is higher than or equal to the specified number, the server executes the statement.
To remove conditional-execution tokens, it's advisable to preserve genuine comments. This can be challenging because they share similar syntax. However, it's important to retain crucial information like:
-- MySQL dump 10.13 Distrib 5.1.41, for Win32 (ia32)
Instead of attempting to remove all comments, consider the following:
Utilizing these principles, you can safeguard valuable comments while streamlining the dumping process.
The above is the detailed content of How Can I Remove Conditional Execution Tokens from MySQL Dumps While Preserving Genuine Comments?. For more information, please follow other related articles on the PHP Chinese website!