我們如何允許 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 也在表中插入無效日期。

更新於: 2020-01-28

273 次瀏覽

助力您的 事業

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.