Reputation: 108
Is there an easy way to add a column to a table that stores when the row was created? Also, is it possible to do this with a column storing when it was last modified as well?
Upvotes: 0
Views: 60
Reputation: 250972
You can create columns with a default value for when the record was created and you can create a column that updates when the record is updated:
CREATE TABLE MyTable(
LastUpdated TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Upvotes: 2
Reputation: 12737
You can do that with a TimeStamp column by having its type as Date and a default value as current_timestamp
Upvotes: 0