SQL Auto-Increment by DateTime

前端 未结 2 700
忘了有多久
忘了有多久 2021-01-06 13:59

Is there a way in my sql to auto increment by the date and time?

so say I have a table

                         mytable
 ============================         


        
2条回答
  •  伪装坚强ぢ
    2021-01-06 14:10

    Run this in your MySQL:

    ALTER TABLE `mytable` 
    CHANGE COLUMN `DateTime` `DateTime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ;
    

    This sets your default value to CURRENT_TIMESTAMP.

提交回复
热议问题