MySQL 使用 ON UPDATE CURRENT_TIMESTAMP 自動更新 timestamp (轉)


 原文地址: https://blog.csdn.net/heatdeath/article/details/79833492

1 `create_time` timestamp not null default current_timestamp comment '創建時間',
2 
3 `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改時間',

當執行update操作是,並且字段有ON UPDATE CURRENT_TIMESTAMP屬性。則字段無論值有沒有變化,它的值也會跟着更新為當前UPDATE操作時的時間。


參考資料:

1、timestamp的兩個屬性:CURRENT_TIMESTAMP 和ON UPDATE CURRENT_TIMESTAMP
https://blog.csdn.net/aitcax/article/details/41849591


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM