gpt4 book ai didi

MySQL datetime 默认时间间隔

转载 作者:可可西里 更新时间:2023-11-01 07:48:27 25 4
gpt4 key购买 nike

是否可以使用 NOW() 添加到默认时间 10 分钟?

我试过类似的东西:

CREATE TABLE `table1` (
`date` DATETIME NOT NULL DEFAULT DATE_ADD(NOW(), INTERVAL 10 MINUTE)
);

但是,它不起作用。

最佳答案

我认为你做不到。

MySQL Documentation指出:

The DEFAULT value clause in a data type specification indicates a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column

关于MySQL datetime 默认时间间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7024010/

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