In MySQL we can have a timestamp column which is automatically set to the current date/time whenever the record is inserted or updated:

In PostgreSQL we can have a timestamp column which is automatically set to the current date/time whenever the record is inserted:

but to have it updated whenever there’s an update in the row we have to write a trigger. First we have to write a function that changes the updated_timestamp column in a table:

then we create the trigger:

there’s still a little difference between MySQL and PostgreSQL, as MySQL will execute the update only whenever there’s an actual update:

but we can add more flexibility adding some conditions to the trigger:

More tables can share the same set_update_timestamp() function if they share the same updated_timestamp column.