如何在 MySQL 中将"0000-00-00"存储为日期?
mysqlmysqli database更新于 2025/3/29 8:44:17
为了将"0000-00-00"之类的日期存储在 MySQL 表的列中,我们必须将 SQL 模式设置为"allow_invalid_date"。以下示例将演示这一点 −
mysql> SET sql_mode = 'allow_invalid_dates';
Query OK, 0 rows affected, 1 warning (0.03 sec)
mysql> Create table test_date(date_order date);
Query OK, 0 rows affected (0.45 sec)
mysql> Insert into test_date(date_order) values('0000-00-00');
Query OK, 1 row affected (0.04 sec)
mysql> Select * from test_date;
+------------+
| date_order |
+------------+
| 0000-00-00 |
+------------+
1 row in set (0.00 sec)
相关文章
有用资源
mysql 参考教程 - 该教程包含有关 mysql 的更多信息:https://www.cainiaomax.com/mysql/

