Strict mode database

Strict mode database

When we write data to the database, the maximum length of the field if the data exceeds the setting, the data is still able to write, 
indicates that the database does not turn on strict mode. In this case, the database will automatically set the maximum length of the field interception, and stored in the database, this will result in erroneous data.

 

Check whether the current strict mode

select @@sql_mode   

Modify the current strict mode

1.

Can be opened by executing SQL statements, but only for the current connection is valid, the following SQL statement is: 

the SET sql_mode = " STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION " ;

 

2.

By modifying the MySQL configuration file, find the sql-mode in the configuration file, modify this line to be:

= the MODE-SQL " STRICT_TRANS_TABLES, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION " 

If you can not find SQL -mode = then added to the [mysqld], the second method is recommended, once and for all.

 

Guess you like

Origin www.cnblogs.com/ghl666/p/11432391.html