Easiest way to create table of 100 sequential integers in a table?

1.3k Views Asked by At

I wish to simply create a table of 100 rows in Aster where each row is a sequential integer. Easily as 1 - 100.

Am trying to do this in Aster/Teradata.

Once I complete it I am going to experiment with random functions.

2

There are 2 best solutions below

1
On

You could just add 100 empty rows into a table with an auto-incrementing primary key starting at 0. I'm not familiar with Aster or Teradata, but with any macro language you it would look something like this:

for i = 0; i < 100; i++
    table.insert(new row())
next
0
On

You can use a recursive CTE, or just basically fake it with row_number. Just find a (preferably small) table with at least 100 rows.

select distinct 
row_number() over (partition by <some column> order by <some column>
from
<your table>
 qualify row_number() over (partition by <some column> order by <some column> <= 100

Or you could use a spreadsheet to build 100 insert statements.