MySQL has sometimes faced criticism for being too relaxed at allowing invalid values, or inserting but truncating values that are out of range. For example:
mysql> CREATE TABLE unsigned_int (a int unsigned); Query OK, 0 rows affected (0.03 sec) mysql> INSERT INTO unsigned_int (a) VALUES (-1); Query OK, 1 row affected, 1 warning (0.01 sec) mysql> SELECT * FROM unsigned_int; +------+ | a | +------+ | 0 | +------+ 1 row in set (0.00 sec)
In MySQL 5.0 two strict sql_mode options were introduced to be able to change this behaviour:
-
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 …