MySQL Timestamp - why all zeros?

前端 未结 4 658
天涯浪人
天涯浪人 2021-02-09 14:28

I\'m using PHPMyAdmin and I\'ve got a MySQL table column called \"timestamp.\" The type (surprise!) is TIMESTAMP, and in \'attributes\' I\'ve set it to ON UPD

4条回答
  •  不要未来只要你来
    2021-02-09 14:43

    If your timestamp column captures only the insertion time then use only

    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    

    Otherwise if it is for modification time then use like as follows

    timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
    

提交回复
热议问题