4 ms·
MySQL does have ON UPDATE for its DATETIME, though; something that Postgres inexplicably still lacks.
by sgarland 2y ago
MySQL does have ON UPDATE for its DATETIME, though; something that Postgres inexplicably still lacks.
- fanf2 2y agoIsn’t ON UPDATE related to foreign keys and independent of the data type? https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-FK https://www.postgresql.org/docs/current/ddl-constraints.html...
- paulryanrogers 2y agoMaybe they're thinking of TIMESTAMP in MySQL, which IIRC would auto update its value on any update to the row. Which was useful for uodated_at like columns. Though I think they later limited it to only the first TIMESTAMP column in a table.
- sgarland 2y agoNo, it works for both [0] types. The first TIMESTAMP thing you’re referring to is that if a specific variable isn’t set, the first TIMESTAMP column automatically gets auto updates applied on creation and update, unless you explicitly defined it to not. This was the default behavior in 5.7, but has since been changed. [0]: https://dev.mysql.com/doc/refman/8.0/en/timestamp-initialization.html https://dev.mysql.com/doc/refman/8.0/en/timestamp-initializa...