mysqldump –add-drop-table option explained
Before we talk about mysqldump –add-drop-table option, we need to understand what happens when you dump a MySQL Database.
When we backup MySQL database using mysqldump command, it actually creating a script file containing multiple SQL Statements. These statements include MySQL queries which will use to restore the database and tables.
What “mysqldump –add-drop-table” option does is, it adds a DROP TABLE statement before each CREATE TABLE statement. So before restoring a table, existing table with the same name will be dropped.
It is important to know that this is the default behavior of the mysqldump command. The DROP TABLE statement will be added to the backup file, even if you did not specify the –add-drop-table option. But you can skip this by using –skip-add-drop-table option. And if you do, you’ll have to remove database tables manually before restore the backup file.