Today encountered a problem, itself in the local Data execution insert SQL nothing wrong, but on the test environment on the error! Find a long time to find out about MySQL configuration. View Local Database
SELECT @ @sql_mode
is empty, the test environment performs the discovery:
+---------------------+
| @ @sql_mode |
+---------------------+
| Strict_trans_tables |
+---------------------+
This mode is equivalent to adding data to SQL, the syntax of the checksum, if you have set NOT NULL but no default value of the field will be reported
Doesn ' t has a default value of error.
Set sql_mode = ""; it's done.
Therefore, when creating the table, it is best to add some non-mandatory fields with NOT NULL plus the default;
Why do you want to set the field to NOT null?
1, empty value is not space-consuming
2. The null in MySQL is actually occupied space , the following is the explanation from the official MySQL
"NULL columns require additional space in the row to record whether their values is null. For MyISAM tables, each of the NULL column takes one bit extra, rounded up to the nearest byte. "
The conditions for null and NULL queries are not the same, and all the best settings are not null!
This article is from the "7804265" blog, please be sure to keep this source http://7814265.blog.51cto.com/7804265/1789338
MySQL insert not NULL no default error (doesn ' t has a default value)