如何默认MySQL日期(时间戳)字段到现在

问题描述 投票:0回答:1

我试过了

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
mysql sql
1个回答
0
投票

使用CURRENT_TIMESTAMP

ALTER TABLE t_granja 
ALTER COLUMN purchase_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
© www.soinside.com 2019 - 2024. All rights reserved.