Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: date类型字段默认值设置
Is there a similar syntax in TiDB for the following MySQL 8 table creation statement?
CREATE TABLE `s22` (
`CreateDate` date DEFAULT (curdate()) COMMENT '创建日期'
);
This can be created in MySQL 8, but is there a similar syntax in TiDB?
7.5+ is compatible with 8+, but versions lower than that do not support this syntax.
Can you try if now() is supported?
DEFAULT CURRENT_TIMESTAMP, like this?
But default current_date doesn’t work.
Referring to the default current value and default current value of our business table, it automatically updates upon udpate:
create_time
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘Creation Time’,
update_time
datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘Update Time’
Supported starting from version v6.6.0.
This is supported, right?
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.