Create Automatic Timestamps in PostgreSQL
Found this at X-Team.
Create Table with Default Timestamp
| |
In creating the todos table, both created_at and updated_at will default
with the current timestamp if one is not given.
This is great for if you are adding items from a CSV and you want to know when
the data is being created.
Update Timestamp on Update
The article also explains how to create a trigger function.
| |
With this function, when can update a table and automatically update column
updated_at with the current timestamp.
| |
This will execute anytime a row is updated in todos.