1. Definition: What is the strict mode of MySQL, in short, MySQL itself to strict data validation (format, length, type, etc.), such as an integer field we write a string type of data, in non-strict mode MySQL will not error, Similarly, if a field of char or varchar type is defined, the data that is written or updated exceeds the defined length without an error. I don't think this is any good for programming, although we try to do data validation in the code. MySQL turned on the strict mode from a certain program to the instructor of our code test, if our development environment does not open strict mode in the development process also did not encounter errors, then on-line or code migration will be possible when the incompatibility of the situation, So in the development process do best to turn on MySQL strict mode.
2. View the SQL schema of the database
Mysql>show variables like ' sql_mode% ';
3. Set the SQL mode to strict mode:
Mysql>setsql_mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution";
This setting is only valid when the database is connected, and is invalidated after exiting the database.
The other is to modify the configuration file for the database: by modifying the MySQL configuration file, looking for Sql-mode in the configuration file and modifying this line as:
Sql-mode= "Strict_trans_tables,no_auto_create_user,no_engine_substitution"
If you do not find sql-mode=, you can add it under [mysqld] and recommend the second method, once and for all.
During the general project development process, strict patterns are used, which facilitates backup and migration of the database.
SQL schema for the database