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

后端 未结 26 2190
野的像风
野的像风 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:39

    While defining multi-line triggers one has to change the delimiter as semicolon will be taken by MySQL compiler as end of trigger and generate error. e.g.

    DELIMITER //
    CREATE TRIGGER `MyTable_UPDATE` BEFORE UPDATE ON `MyTable`
    FOR EACH ROW BEGIN
            -- Set the udpate date
        Set new.UpdateDate = now();
    END//
    DELIMITER ;
    

提交回复
热议问题