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

后端 未结 26 2184
野的像风
野的像风 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条回答
  •  灰色年华
    2020-11-22 02:35

    CREATE TABLE `testtable` (
        `id` INT(10) NULL DEFAULT NULL,
        `colname` DATETIME NULL DEFAULT '1999-12-12 12:12:12'
    )
    

    In the above query to create 'testtable', i used '1999-12-12 12:12:12' as default value for DATETIME column colname

提交回复
热议问题