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