How to Create Date Incrementing Trigger in Postgresql

38 Views Asked by At

I'm not very experienced in Postgresql, and in a personal project I have the table column ID (Primary Key) being a date with format yyyy-mm-dd, like this

ID
---
2020-07-12
2020-07-13
2020-07-14

I want to create a trigger so that ID value gets automatically incremented (based on latest ID value) when a new record is inserted. Also what is the recommended data type for the column ID in this case?

My goal The table stores Daily Report summaries, it's already known that new record will be the next day and I want to eliminate the need to specify the report's Date manually. Report data is inserted using service call to application, and reducing the payload params to the minimum is important.

0

There are 0 best solutions below