gpt4 book ai didi

mysql - DATETIME 和 TIMESTAMP 长度/值错误

转载 作者:可可西里 更新时间:2023-11-01 07:02:30 41 4
gpt4 key购买 nike

我使用 int 类型来存储日期时间类型的数据。为了方便从 MySQL 获取特定范围内的数据,我尝试将其更改为 TIMESTAMP/DATETIME 但它给出了 the attached image 中的错误。在这两种情况下。数据类型 TIMESTAMP/DATETIME 的格式为 YYYY-MM-DD HH:MM:SS,长度为 19 个字符。

我无法获得适当的教程/文章来了解此错误/问题。

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)]

文档:

关于mysql - DATETIME 和 TIMESTAMP 长度/值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38684276/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com