PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.18. 誫啂镖劽䔇庘昄

橸誗柟誄闼底埇脘誫啂崔庯婔臯䔇庘昄㔗䕞嬉認婻䌂傋䔇庘昄埻橬废彖埙䫘潊庘昄套臘9-39欔誄㔗

臘9-39. 废彖埙䫘潊庘昄

庘昄埗昄䌂傋誫啂䌂傋柟誄
generate_series(start, stop)intbigintsetof intsetof bigint (婯埗昄䌂傋䕩劯)䫘潊婔婻昄唚废彖傯 startstop 準阪婺 1 㔗
generate_series(start, stop, step)intbigintsetof intsetof bigint (婯埗昄䌂傋䕩劯)䫘潊婔婻昄唚废彖傯 startstop 準阪婺 step

套悩 step 滇溼昄婫 start 崓庯 stop 闼幽誫啂镽臯㔗䕩埉套悩 step 滇蘘昄婫 start 償庯 stop 闼幽幘誫啂镽臯㔗套悩膷噖滇 NULL 劯湙库䫘镽臯㔗step 婺镽彍滇婔婻髍臇㔗婋麵滇婔底冋床

select * from generate_series(2,4);
 generate_series
-----------------
               2
               3
               4
(3 rows)

select * from generate_series(5,1,-2);
 generate_series
-----------------
               5
               3
               1
(3 rows)

select * from generate_series(4,3);
 generate_series
-----------------
(0 rows)

select current_date + s.a as dates from generate_series(0,14,7) as s(a);
   dates
------------
 2004-02-05
 2004-02-12
 2004-02-19
(3 rows)

劯锔饡釕嬉誕
臯启昄䂇懫膄婪婔亓係䂘媇敇庘昄