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.

有帮助吗?

解决方案

You can use rownum for that:

select rownum + 999
from   your_table

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top