ALLOW_INVALID_DATES SQL 模式是用来做什么的?
正如其名,启用 ALLOW_INVALID_DATES SQL 模式将允许我们在表中存储无效日期。以下示例可以帮助理解 −
示例
mysql> SET sql_mode = ALLOW_INVALID_DATES; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> Insert Into detail_bday(Name, Birth_Date) values('Sonia','1993-11-31'); Query OK, 1 row affected (0.09 sec) mysql> Insert Into detail_bday(Name, Birth_Date) values('Ram','0000-00-00'); Query OK, 1 row affected (0.10 sec) mysql> Select * from detail_bday; +----+---------+------------+ | Sr | Name | Birth_Date | +----+---------+------------+ | 1 | Saurabh | 1990-05-12 | | 2 | Raman | 1993-06-11 | | 3 | Gaurav | 1984-01-17 | | 4 | Rahul | 1993-06-11 | | 5 | Sonia | 1993-11-31 | | 6 | Ram | 0000-00-00 | +----+---------+------------+ 6 rows in set (0.00 sec)
上述结果集表明,在启用 ALOOW_INVALID_DATES SQL 模式后,MySQL 允许我们存储无效日期,如 '1993-11-31' 和 '0000-00-00'。
广告