Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql: How to repeat query as soon as finished?

Let's say I have a query like so:

SELECT * FROM a WHERE a.Category = 'liquid' ORDER BY a.MeasurementTime DESC;

and I want to see the results coming into the database 'live'.

How can I write a query for Postresql which will repeat as soon as the query finishes?

like image 407
pookie Avatar asked Jun 27 '17 09:06

pookie


1 Answers

You can use the \watch n command in the terminal to re-execute the query every n seconds.

Example:

postgre=# SELECT * FROM TABLE WHERE CONDITION
postgre=# \watch 5
-- now the "SELECT * FROM TABLE WHERE CONDITION" is re-executed every 5 seconds
like image 177
Eric Avatar answered Oct 07 '22 15:10

Eric