我们如何在MySQL中提供仅包含年份(零个月零天)值的日期?
通过禁用NO_ZERO_IN_DATE模式,我们可以在MySQL表中存储仅包含年份值且具有零个月和零天的日期。如果启用此模式,则MySQL会将此类日期视为无效日期,并存储所有零。
mysql> Insert into year_testing (OrderDate) values('2017:00:00');
mysql> select * from year_testing;
+------------+
| OrderDate |
+------------+
| 2017-00-00 |
+------------+
1 row in set (0.00 sec)
mysql> SET sql_mode = 'NO_ZERO_IN_DATE';
mysql> Insert into year_testing(OrderDate) values('2017:00:00');
mysql> Select * year_testing;
+------------+
| OrderDate |
+------------+
| 2017-00-00 |
| 0000-00-00 |
+------------+
1 rows in set (0.00 sec)热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短