I have an application to authenticate the user based on a one time password.
This password is stored in the db with the username.
I wish to keep the OTP valid only for a certain period of time after that i want to
get rid of that particular entry.
my table uses the user name as primary key.
I have an application to authenticate the user based on a one time password.
Share
There aren’t any time-based triggers offered by PostgreSQL.
What you usually want to do in this situation is insert the records with an expiry time. When you look them up, use
SELECT ... FROM the_table WHERE expiry_time < current_timestamp;.Have a periodic cleanup job remove old expired records using an external cron job, script, or tool like PgAgent.