Pregunta

I need a sql query where I get a column with an increasing id starting with 1000.

The background is I have to insert a large number of data sets in a table and use the existing data and copy (insert with sub select). But the id has to be unique so I need a select statment which generates id's each increased by 1. (I can't use auto increment because I can't change the table.) How can I do that?

Thanks.

¿Fue útil?

Solución

You can use rownum for that:

select rownum + 999
from   your_table

This will let the counting start at 1000 (first row = 1+999)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top