It is possible to set default value on DATE (NOT DATETIME) column in MySQL 5.7 to current date?
I try this (generated by Workbench):
ALTER TABLE `db`.`table` CHANGE COLUMN `column` `column` DATE NOT NULL DEFAULT CURDATE() ;
but not works for me. (no data in table)
There is a way you can do this if you have another column that has a for example a datetime field with a default of NOW(). See this post:
No, you cannot. The documentation is pretty clear on this:
You can do one of the following:
DATETIME
. Create view that extracts the date as a separate column.insert
trigger to set thedate
column.