我读自 MySQL manual DATETIME 数据类型中不允许使用 1000 年之前的年份:
The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD HH:MM:SS' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.
有人可以向我解释一下这段代码是如何工作的吗:
CREATE TABLE testing_dates(
test_date DATETIME
);
INSERT INTO testing_dates
VALUES ('0001-12-22 12:12:12');
最佳答案
在您链接到的同一页面上,它显示:
For the DATE and DATETIME range descriptions, “supported” means that although earlier values might work, there is no guarantee.
我将此解释为他们对受支持的范围进行了软件测试,但不对范围之外的值进行了软件测试。
关于MySQL 允许 1000 年之前的日期吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42045479/