I have a 500,000 line SQL script:
update users set region_id = 9814746 where id = 101 and region_id is null; update users set region_id = 9814731 where id = 102 and region_id is null; update users set region_id = 3470676 where id = 103 and region_id is null;
I want to INSERT a delay of 10
seconds every 50
lines. Does pgsql
have a waitfor
statement like t-sql
.
Thanks.
Using WAITFOR DELAY with a local variable. The following example shows how a local variable can be used with the WAITFOR DELAY option. This stored procedure waits for a variable period of time and then returns information to the user as the elapsed numbers of hours, minutes, and seconds.
WAITFOR DELAY – This option can be used to pause a query for a certain duration of time. Time to pass before a query is executed. For example, we can delay the execution of a query by seconds/ minutes or hours. WAITFOR TIME – Other option to pause a query execution until a specified time of a day is reached.
In Sql Server to PAUSE OR SLEEP OR WAIT the execution of the script for specified period of time say 10 hours or 10 minutes or 10 seconds or 10 millisecond etc we can use the WAITFOR DELAY command.
Does pgsql have a waitfor statement like t-sql.
Yes, pg_sleep:
pg=> SELECT pg_sleep(10); pg_sleep ---------- (1 row)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With