我正在尝试以下SQL语句:
create table sample (
id int not null primary key auto_increment,
name varchar(100),
date_modified timestamp not null default current_timestamp on update current_timestamp,
date_created timestamp not null default now()
)它不工作..。我得到以下错误:
#1293 - Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause我需要跟踪两个日期戳,一个是该行的创建日期,另一个是该行的最后修改日期。它们都能做我想要的事情,我单独使用它们,但是MySQL不允许我将它们组合到一个表中。
请帮帮忙。:)
发布于 2010-12-22 09:25:34
您可以在其中创建触发器BEFORE UPDATE和修改date_modified。
或者BEFORE INSERT,然后在那里创建date_created。
https://stackoverflow.com/questions/4505374
复制相似问题