How do you set a default value for a MySQL Datetime column?

后端 未结 26 2181
野的像风
野的像风 2020-11-22 01:55

How do you set a default value for a MySQL Datetime column?

In SQL Server it\'s getdate(). What is the equivalant for MySQL? I\'m using MySQL 5.x if tha

26条回答
  •  -上瘾入骨i
    2020-11-22 02:22

    If you set ON UPDATE CURRENT_TIMESTAMP it will take current time when row data update in table.

     CREATE TABLE bar(
            `create_time` TIMESTAMP CURRENT_TIMESTAMP,
            `update_time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
        )
    

提交回复
热议问题