PostgreSQL reset a value to default daily?

I have my own database server that is on 24/7. What I want is to have a column that will reset its value to default daily. How do I do this?

For example,

Table(Int ColmA, ColmB)

ColmA has a default value of 5 and it will get decrement by some application. How do i make it to reset the value back to 5 daily?


The easiest way is to use crontab. Run in terminal:

crontab -e

(on some systems you need to switch to postgres user beforehand: sudo su postgres && crontab -e) and type in editor something like:

0 0 * * * psql <your_database_name> -c "UPDATE YourTable SET ColmA = 5"

Quit the editor. From now on every midnight UPDATE query will be executed.

Need Your Help

Load 3 user controls (web application) on their own threads

c# multithreading user-controls

I have 3 user controls that pull data from the database and display a gridview. I need all of these 3 gridviews to run at the same time.

How to overcome PathTooLongException?

c# path pathtoolongexception

So I am writing a program that will scan for duplicate files on a computer as the programs that I've seen are really slow, and/or memory hogs, but I was running into a PathTooLongException when I t...