Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
Delete range of rows using generate_series()?

To update every row in a table, I use this query (and it's working):

enter image description here

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?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Use USING:

DELETE from test2 
       using generate_series(1, 1000) idx
       WHERE id = idx
over 4 years ago · Santiago Trujillo Denunciar

0

What is the best practice for this kind of operation?

You can use generate_series() like Gordon demonstrates. This might even make sense for non-integer types or with an increment <> 1.
For simple cases, the simple query is superior, though:

DELETE FROM test2 
WHERE  id BETWEEN 1 AND 1000;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda