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”之类的无效日期。
广告