To update every row in a table, I use this query (and it's working):
I wonder if I can use a similar notation for DELETE
?
Something like:
DELETE from test2
from generate_series(1, 1000) as idx
WHERE id = idx;
Won't work as the second FROM
is invalid, of course. Any idea how to fix that?
What is the best practice for this kind of operation?
Use USING
:
DELETE from test2
using generate_series(1, 1000) idx
WHERE id = idx