1、養成良好習慣,先點贊后觀看;你看隔壁老王都點贊了!
看了些博客說mysql記錄創建時間和更新時間:創建表如圖:
創建時間和更新時間:
createtime timestamp default current_timestamp,
updatetime timestamp on update current_timestamp
2、同樣是5.7版本,可能是版本號不同,不能兼容;當使用方法一創建update時就會報沒有默認值的錯誤。
所以:
updatetime默認值為空:
createtime timestamp default current_timestamp,
updatetime timestamp null on update current_timestamp
updatetime默認值為當前時間:
3、但是版本低於5.5的mysql卻不行;所以只能另想辦法,先弄創建時間,然后弄個觸發器,每次更新都觸發獲取當時時間;
搞定、、、、