是否可以使用 NOW() 添加到默认时间 10 分钟?
我试过类似的东西:
CREATE TABLE `table1` (
`date` DATETIME NOT NULL DEFAULT DATE_ADD(NOW(), INTERVAL 10 MINUTE)
);
但是,它不起作用。
最佳答案
我认为你做不到。
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/