I have a MySQL table with some dates, I need that one of them have a default value equal to current time, I'm using 'Sequel Pro' to build the database, Then i wrote 'now()' (and 'GETDATE()') in default value, but doesn't work.
Can someone do help me, How 'Set Default value' to 'NOW()' with Sequel PRO?
ERROR:
An error occurred when trying to change the field 'DataDoPedido' via
ALTER TABLE
Reserva
CHANGEDataDoPedido
DataDoPedido
DATE NOT NULL DEFAULT 'now()'MySQL said: Invalid default value for 'DataDoPedido'
thanks.
For MySQL, the DEFAULT
specified for a column must be a constant; it cannot be the return from a function. The one exception to this is the TIMESTAMP
datatype, which can have a DEFAULT CURRENT_TIMESTAMP
.
If you need to initialize a DATE
column, one workaround is to create a BEFORE INSERT ON
trigger.