并没有设置严格模式,怎么还是输入0000-00-00?
并没有设置严格模式,怎么还是输入0000-00-00,而不是显示输入的无效日期?mysql> show variables like 'sql_mode';
+---------------+---------------------+
| Variable_name | Value |
+---------------+---------------------+
| sql_mode | ALLOW_INVALID_DATES |
+---------------+---------------------+
1 row in set (0.00 sec)
mysql> select * from date1;
Empty set (0.00 sec)
mysql> insert into date1 values ('2001-13-40');
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> show warnings;
+---------+------+--------------------------------------------+
| Level | Code | Message |
+---------+------+--------------------------------------------+
| Warning | 1265 | Data truncated for column 'date1' at row 1 |
+---------+------+--------------------------------------------+
1 row in set (0.00 sec)
mysql> select * from date1;
+------------+
| date1 |
+------------+
| 0000-00-00 |
+------------+
1 row in set (0.00 sec)
月份只能在1~12之间,日只能1~31之间,超过这些时间界定也会变成0000,若要强行建议更换数据类型为字符串 KAiTO 发表于 2023-3-15 10:41
月份只能在1~12之间,日只能1~31之间,超过这些时间界定也会变成0000,若要强行建议更换数据类型为字符串 ...
谢谢大佬
页:
[1]