gpt4 book ai didi

mysql - 如何将 MySQL 日期(时间戳)字段设置为默认值

转载 作者:行者123 更新时间:2023-11-29 16:08:46 25 4
gpt4 key购买 nike

我已经尝试过

alter table t_granja ALTER COLUMN purchase_date TIMESTAMP DEFAULT now();

但我收到一个错误

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TIMESTAMP DEFAULT now()' at line 1

最佳答案

使用CURRENT_TIMESTAMP

ALTER TABLE t_granja 
ALTER COLUMN purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP;

关于mysql - 如何将 MySQL 日期(时间戳)字段设置为默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55482384/

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