Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL flags in dumps

Tags:

mysql

Looking at a mySQL Dump, I have come across something and like to know what they are.

I see:

/*!50001 DROP TABLE IF EXISTS `xxx` */;

What is the flag 50001, is there a list of what they mean?

like image 811
Jamie Teuma Avatar asked Feb 18 '14 13:02

Jamie Teuma


People also ask

What is MySQL dump command?

Mysqldump is a command-line utility that is used to generate the logical backup of the MySQL database. It produces the SQL Statements that can be used to recreate the database objects and data. The command can also be used to generate the output in the XML, delimited text, or CSV format.

Which flag allows you to dump all the database table entries?

To dump large tables, you could combine the following two flags, --single-transaction and --quick .

How does MySQL dump work?

4 mysqldump — A Database Backup Program. The mysqldump client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. It dumps one or more MySQL databases for backup or transfer to another SQL server.


1 Answers

It is discussed on the MySQL's forums/mailing lists here.

/*!50001 DROP TABLE `category_count_view`*/; 

This is a "feature" of MySQL. Any other RDBMS will treat this as a comment.

But, MySQL looks at 50001 and checks that as a MySQL version. This is Version 5.00.01, or 5.0.1 in the real world, but leaves room for the the sub-version and release to be greater than 9.

MySQL will treat the line as a comment if MySQL is below 5.0.1, and will process the line if MySQL is greater than or equal to 5.0.1.

It's a way making a SQL script compatible with different versions of MySQL, and allows new features to be included.

like image 146
hjpotter92 Avatar answered Nov 16 '22 01:11

hjpotter92