連番データ生成

(8.0.22)

set @i:=0; select @i:=@i+1 from information_schema.columns limit 1000;

with recursive t1(col1) as(
select 1 from dual
union all
select col1 + 1
from t1
where col1 + 1 <= 1000
)
select col1 from t1
;

select row_number() over(order by table_catalog) from information_schema.columns limit 1000;

(19c)
select rownum from dual connect by level <= 1000;

with t1(col1) as(
select 1 from dual
union all
select col1 + 1
from t1
where col1 + 1 <= 1000
)
select col1 from t1
;

select row_number() over(order by owner) from dba_tab_columns fetch first 1000 rows only;

 

(13)

select generate_series(1,1000);

with recursive t1(col1) as(
select 1
union all
select col1 + 1
from t1
where col1 + 1 <= 1000
)
select col1 from t1
;

select row_number() over(order by table_catalog) from information_schema.columns limit 1000;

(2019)

with t1(col1) as(
select 1
union all
select col1 + 1
from t1
where col1 + 1 <= 1000
)
select col1 from t1
OPTION (MAXRECURSION 0);

select top 1000 row_number() over(order by object_id) from sys.columns;

 

(2022)
https://learn.microsoft.com/ja-jp/sql/t-sql/functions/generate-series-transact-sql?view=sql-server-ver16
https://www.dbsheetclient.jp/blog/


select value from generate_series(1,1000);