Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

DEFAULT CURRENT_TIMESTAMP

kalvaro's profile image kalvaro posted 11 years ago in Running SQL scripts Permalink
I'm getting a SQL error when I try to add a column. HeidiSQL generates this query:

ALTER TABLE `folder` ADD `updated` DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL;


And the SQL Server returns this error: Invalid default value for 'updated'

I understand the issue comes from the server, which is pretty old (4.1.13). However, I can't manage to find the exact reference in the MySQL manual. I'd like to know for sure what I can and I cannot do with CURRENT_TIMESTAMP depending on the server version.

Any clue?
ansgar's profile image ansgar posted 11 years ago Permalink
No, I'm nearly sure you have to set the datatype to TIMESTAMP rather than DATETIME for "CURRENT_TIMESTAMP" to be a valid default value.
kalvaro's profile image kalvaro posted 11 years ago Permalink

No, I'm nearly sure you have to set the datatype to TIMESTAMP rather than DATETIME for "CURRENT_TIMESTAMP" to be a valid default value.



You are right, I can add a TIMESTAMP column with such default value even in MySQL 4.1... The manual page seems to be this:

http://dev.mysql.com/doc/refman/4.1/en/timestamp.html

I'll check whether there's already a feature request for HeidiSQL so it hides invalid default values in the drop down list.

Thanks for the tip!

Please login to leave a reply, or register at first.