Question:
How can I fill a numeric field with a sequence of numbers using SQL?
For example, I want a field named NUMBER to contain the numbers 1 for the first row, 3 for the second row, 5 for the third row, etc.
Answer:
There are several ways to approach this. The easiest would be to make the field a serial field type. Then you’d just do an “INSERT into table_name (fieldname) values (0)”. The value inserted will be the next one in the sequence.
You could also enable ROWIDS and do some type of manipulation on that value. It depends on what you mean by first row. None of the methods will actually set the physical position of the row in the database, but that’s academic. You could do a SELECT/ORDER BY on the numeric field to bring the data back in the order you wish.