Question

When am trying to set default date and default sysdate am getting following errors:

MySQL Query:

create table product_offer_type(object_id INT(19), snapshot_id INT(19), PRIMARY KEY(object_id,snapshot_id), enum_value VARCHAR(64) NOT NULL, external_name VARCHAR(64) NOT NULL, description VARCHAR(255), business_validation INT(1), valid_for_start_date_time DATE  DEFAULT '1900-01-10', valid_for_end_date_time DATE  DEFAULT '4712-01-01', mutation_date_time DATE SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER');

Error Message:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SYSDATE, mutation_user VARCHAR(32) DEFAULT 'USER')' at line 1

Any pointer's would be highly appreciated.

Was it helpful?

Solution

If you're trying to track the last modification time of the row, I usually use something like

mutation_date_time timestamp default current_timestamp, on update current_timestamp

You might need slight modification if you really want Date and not timestamp.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top