mysql 表字段 dateime timestamp

    datetime YYYY-MM-DD HH:MM:SS 日期和時間的組合;

     timestamp 時間戳

建表時候想使用時間的自更新設置。

在將字段設置爲 datetime時,默認設置爲 null  on_update_current_timetamp時候報錯:

最後發現,該默認值 on_update_current_timestamp 是timestamp的默認值設置。

而且 對於表中用於記錄插入、更新時間的字段一般使用timestamp字段 。

且一個表只允許一個字段使用on_update_current_timestamp 或者current_timestamp 。

所以:

對於create_time使用 timestamp  默認 無

對於update_time使用timestamp  默認  on_update_current_timestamp  current_timestamp

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章