mysql 5.6中关于STRICT_TRANS_TABLES的讨论
在mysqlteam的成员Morgan Tocker的博文http://www.tocker.ca/2014/01/14/making-strict-sql_mode-the-default.html中,提到了mysql 5.6中默认用的是严格模式了,就是在my.cnf中
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
其中:
STRICT_ALL_TABLES - Behave more like the SQL standard and produce errors when data is out of range.
STRICT_TRANS_TABLES - Behave more like the SQL standard and produce errors when data is out of range, but only on transactional storage engines like InnoDB.
由于mysql 5.6默认用innodb ,所以用STRICT_TRANS_TABLES也容易理解。用了这个选项的话,
那么数据库中如果是非空值的话就得设置默认值了,否则是报错的
此外,在http://www.tocker.ca/2013/11/01/proposal-to-simplify-sql-modes.html中还提到要去掉多余的sql_mode,比如:
ERROR_FOR_DIVISION_BY_ZERO, NO_ZERO_DATE and NO_ZERO_IN_DATE.
不过这好像还在讨论阶段