且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MySQL(DEFAULT + ON UPDATE)TIMESTAMPs

更新时间:2023-02-20 09:25:56

YES WE CAN.

You can use a trigger to update the field, like so:

create trigger CreationTimestamp after insert on MyTable for each row
begin
    update MyTable set CreateField = UpdateField where id = new.id
end

This way, you can set your auto-update field using the native MySQL method, and use this to capture the creation date.