Database Reference
In-Depth Information
This line starts by specifying that the command will be executed only if the version of
MySQL or MariaDB is at least 4.01.01. mysqldump makes sure in this way that it won't
try to invoke a feature on old versions of databases that don't support the feature. It's as-
sumed that once a feature is supported, all future versions of the server will continue to
support it. The SQL statement that follows saves the current value ofthe
CHARACTER_SET_CLIENT global variable. If you look back at Example14-1 , you'll
see that the subsequent linessave CHARACTER_SET_RESULTS and
COLLATION_CONNECTION aswell. The fourth line then sets all three variables to ut-
f8 with NAMES — that's an abbreviation for these three variables.
If you skip to the very end of the dump file, you'll see a similar batch of SQL statements
that look like this:
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */ ;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */ ;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */ ;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */ ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */ ;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */ ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */ ;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */ ;
-- Dump completed on 2014-09-14 6:13:40
These conditional SQLstatements reverse the first batch of conditional SQL statements.
They use the variables that were created at the start to set the global variables back to their
old settings. You'll see many conditional statements like these throughout the dump file.
This resetting of key characteristics makes it important to lock tables when restoring a
dump file, so that the results of such SET statements won't affect any data changes that
users might make during the restoration of a database.
Let's go back to the start of the dump file and look at the lines that follow the initial con-
ditional SQL statements. You should see something like this:
--
-- Current Database: `rookery`
--
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `rookery`
/*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_bin */;
USE `rookery`;
Search WWH ::




Custom Search