Zach
Zach

Reputation: 37

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

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.

Upvotes: 1

Views: 1615

Answers (2)

Andrew
Andrew

Reputation: 8703

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.

Upvotes: 2

Eric
Eric

Reputation: 1472

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

Upvotes: 1

Related Questions