DATETIME 和 TIMESTAMP Length/Values 错误
DATETIME and TIMESTAMP Length/Values Error
我使用 int
类型来存储日期时间类型的数据。为了方便获取 MySQL 特定范围内的数据,我尝试将其更改为 TIMESTAMP/DATETIME
但在这两种情况下它都给出了 the attached image 中的错误。数据类型 TIMESTAMP/DATETIME
的格式为 YYYY-MM-DD HH:MM:SS
,长度为 19 个字符。
我无法获得适当的 tutorial/article 来了解这 error/issue。
Error Image
定义 DATETIME 或 TIMESTAMP 字段时,无需指定长度。
这是错误消息所指的内容:
A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision
MySQL permits fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision. To define a column that includes a fractional seconds part, use the syntax type_name(fsp), where type_name is TIME, DATETIME, or TIMESTAMP, and fsp is the fractional seconds precision. For example:
CREATE TABLE t1 (t TIME(3), dt DATETIME(6));
来自 CREATE TABLE Syntax 的摘要:
| TIME[(fsp)]
| TIMESTAMP[(fsp)]
| DATETIME[(fsp)]
文档:
我使用 int
类型来存储日期时间类型的数据。为了方便获取 MySQL 特定范围内的数据,我尝试将其更改为 TIMESTAMP/DATETIME
但在这两种情况下它都给出了 the attached image 中的错误。数据类型 TIMESTAMP/DATETIME
的格式为 YYYY-MM-DD HH:MM:SS
,长度为 19 个字符。
我无法获得适当的 tutorial/article 来了解这 error/issue。
Error Image
定义 DATETIME 或 TIMESTAMP 字段时,无需指定长度。
这是错误消息所指的内容:
A DATETIME or TIMESTAMP value can include a trailing fractional seconds part in up to microseconds (6 digits) precision
MySQL permits fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microseconds (6 digits) precision. To define a column that includes a fractional seconds part, use the syntax type_name(fsp), where type_name is TIME, DATETIME, or TIMESTAMP, and fsp is the fractional seconds precision. For example:
CREATE TABLE t1 (t TIME(3), dt DATETIME(6));
来自 CREATE TABLE Syntax 的摘要:
| TIME[(fsp)]
| TIMESTAMP[(fsp)]
| DATETIME[(fsp)]
文档: