是否有办法将MySQL发出的关于无效日期的警告转化为硬错误? 我利用<代码>SET sql_mode=TRADITIONAL ;进行了尝试,显然应当将(有些)警告变成错误,但在此没有任何效果。 这是MySQL.1.56。 在届会一级开展这项工作是理想的,但我不胜感激。
mysql> describe test_table2;
+----------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| value | int(11) | YES | | NULL | |
| name | varchar(16) | YES | | NULL | |
| sometime | datetime | YES | | NULL | |
+----------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
mysql> select * from test_table2;
+-------+-------+---------------------+
| value | name | sometime |
+-------+-------+---------------------+
| 1 | one | 2002-09-01 10:00:00 |
| 2 | two | 2002-09-02 11:00:00 |
| 3 | three | 2002-09-03 12:00:00 |
| 4 | four | 2002-01-04 13:00:00 |
| 5 | five | 2002-01-05 14:00:00 |
+-------+-------+---------------------+
5 rows in set (0.00 sec)
mysql> select * from test_table2 where sometime = foo ;
Empty set, 2 warnings (0.00 sec)
Warning (Code 1292): Incorrect datetime value: foo for column sometime at row 1
Warning (Code 1292): Incorrect datetime value: foo for column sometime at row 1