看到暐翰分享的 SQLServer不需要遞迴,使用spt_values快速生成連續整數0-2048
https://ithelp.ithome.com.tw/articles/10229752
我也來一段
with t1 as (
select array_agg(oid) as arr1
from pg_class
)
select sn
from t1
join lateral
unnest(arr1) with ordinality as gs(elem, sn)
on true
limit 100
;
+-----+
| sn |
+-----+
| 1 |
| 2 |
| 3 |
| 4 |
....
| 98 |
| 99 |
| 100 |
+-----+
(100 rows)
在之前介紹 Array 時就有使用過這個技巧.
https://ithelp.ithome.com.tw/articles/10222763?sc=rss.iron