为什么我更新一列但另一列(时间戳)也会自动更新系统当前时间
数据库mysql:
我执行的示例sql语句
select id, processstatus, processtimestamp from mytable where id=229;
id processstatus processtimestamp
--------- ---------------------------------------------------------------------------------------------------- -------------------------
229 EXPORT_FILEA.txt 2015-11-04 12:54:49.0
update mytable set processstatus='EXPORT_TO_FILE_B' where id=229;
select id, processstatus, processtimestamp from mytable where id=229;
id processstatus processtimestamp
--------- ---------------------------------------------------------------------------------------------------- -------------------------
229 EXPORT_TO_FILE_B 2015-11-04 13:09:41.0
答案 0 :(得分:0)
您可以像这样创建CURRENT_TIMESTAMP
列: -
ALTER TABLE `table` ADD `col_name` DATETIME
on update CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;
尝试此查询: -
ALTER TABLE `table` CHANGE `col_name` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;
删除
on update CURRENT_TIMESTAMP