Hello everyone

Encountered a problem while ago
There is a table such as the following

CREATE TABLE IF NOT EXISTS `gg02` (
     `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `case` varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;

Then when I use

SHOW VARIABLES LIKE 'sql_mode';

Get the argument is '' (null)

Then use

 

INSERT INTO `test`.`gg02` (`id`, `name`) VALUES (NULL, 'cccc');

Can operate normally

But the focus here

If I set the mysql current sql_mode
STRICT_TRANS_TABLES

will be

#1364 - Field 'case' doesn't have a default value

Such errors

Why?

http://dev.mysql.com/doc/refman/5.5/en/sql-mode.html
Written inside

Strict SQL Mode
Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons
嚴格模式控制的MySQL處理的數據,如INSERT或UPDATE無效或遺漏值則都會報錯

So La
If this error occurs when writing

Solutions
1. Modify the mysql settings, remove the STRICT_TRANS_TABLES sql_mode
Use

set global sql_mode = ""


But pay attention to whether there is authority


2.fix the problem Query

I hope to be helpful
Thanksgiving!