首页  >  文章  >  数据库  >  我们怎样才能让MySQL存储无效的日期呢?

我们怎样才能让MySQL存储无效的日期呢?

WBOY
WBOY转载
2023-09-09 15:13:02981浏览

我们怎样才能让MySQL存储无效的日期呢?

将 SQL 模式启用为 ALLOW_INVALID_DATES 后,MySQL 还将能够在表中存储无效日期。下面给出了示例来理解它 -

mysql> Insert into order1234(ProductName, Quantity, Orderdate) values('B',500,'2015-11-31');
Query OK, 1 row affected (0.06 sec)

mysql> Select * from order1234;
+-------------+----------+--------------+
| ProductName | Quantity | OrderDate    |
+-------------+----------+--------------+
| A           | 500      | 0000-00-00   |
| B           | 500      | 2015-11-31   |
+-------------+----------+--------------+
2 rows in set (0.00 sec)

我们可以看到 MySQL 也在表中插入了无效日期。

以上是我们怎样才能让MySQL存储无效的日期呢?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:tutorialspoint.com。如有侵权,请联系admin@php.cn删除