Bug #52350 cannot set ON UPDATE CURRENT_TIMESTAMP as default value
| Submitted: | 25 Mar 2010 0:19 | Modified: | 27 May 2010 9:49 |
|---|---|---|---|
| Reporter: | Ari Awan | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Workbench | Severity: | S1 (Critical) |
| Version: | 5.2.16 | OS: | Any |
| Assigned to: | Alexander Musienko | CPU Architecture: | Any |
| Tags: | current_timestamp, default value, timestamp | ||
[25 Mar 2010 0:19]
Ari Awan
[25 Mar 2010 12:22]
Johannes Taxacher
problem is that parser inserts the keyword DEFAULT even if you only enter "ON UPDATE CURRENT_TIMESTAMP" as a workaround, you could specify the default value of NULL (or a zero timestamp in case of a not-null field)
[25 Mar 2010 12:23]
Johannes Taxacher
but i could not repeat the "reverse engineering doesn't pick it up from DB" problem. this part is woring fine here
[25 Mar 2010 13:06]
Ari Awan
I am sorry I dont understand how to implement the work around, if i specify the default property to NULL , how do I specify "ON UPDATE CURRENT_TIMESTAMP" in the model?
[25 Mar 2010 13:13]
Johannes Taxacher
by entering following test into the default-field in column editor: NULL ON UPDATE CURRENT_TIMESTAMP
[25 Mar 2010 13:15]
Johannes Taxacher
or, if you event want to have the CURRENT-TIMESTAMP in the field when the data is first inserted you could write: CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP because the "on update ..." clause only gets activated on an actual update of the data, not on initial insert)
[25 Mar 2010 13:56]
Peter Laursen
The first timestamp defined TIMESTAMP NOT NULL is automatically becoming a TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRRENT_TIMESTAMP. That works like that with any client that works directly with the MySQL server. Problem is that WB does not work directly with the MySQL server - only when sync'ing or forward engineering the WB internal model is known by the server. But it could be a workaround the TIMESTAMP NOT NULL, forward engineer and reverse engineer. Besides I disagree with the premises of this discussion: In my understanding there is no DEFAULT-clause 'ON UPDATE CURRRENT_TIMESTAMP' and also no DEFAULT-clause 'CURRENT_TIMESTAMP ON UPDATE CURRRENT_TIMESTAMP'. There is a DEFAULT-clause 'CURRRENT_TIMESTAMP' and a ON UPDATE-clause 'CURRRENT_TIMESTAMP'. Two *different* spec's for that column and not one. The ON UPDATE-clause is special in the sense that it can only be used for TIMESTAMP types/columns and only the value 'CURRRENT_TIMESTAMP' can be specified for it. Peter (not a MySQL person)
[26 May 2010 15:22]
Johannes Taxacher
fix confirmed in repository
[27 May 2010 9:49]
Tony Bedford
An entry has been added to the 5.2.22 changelog: It was not possible to set ON UPDATE CURRENT_TIMESTAMP as the default value for a column.
[15 Nov 2022 23:59]
Eric Egana
Just had the same problem with "ON UPDATE CURRENT_TIMESTAMP" getting an invalid SQL syntax error. Putting "NULL ON UPDATE CURRENT_TIMESTAMP" gave me an error that said invalid default value. Then I tried "0 ON UPDATE CURRENT_TIMESTAMP" and this worked.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.063 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.