오라클에서는 아래와 같은 구문으로 로우를 원하는 수 만큼 늘릴수 있습니다.
SQL> select level from dual connect by level <= 5;
LEVEL
----------
1
2
3
4
5
PostgreSQL 에서는 아래와 같은 구문으로 똑같이 구현할수 있습니다.
scott@pg-00:5432:scottdb]
SQL> select gs.id from generate_series(1,5) gs(id);
id
----
1
2
3
4
5
(5 rows)
scott@pg-00:5432:scottdb]
SQL> select generate_series(1,5) id;
id
----
1
2
3
4
5
(5 rows)
scott@pg-00:5432:scottdb]
SQL>
이렇게 활용이 가능합니다.
SQL> select cast(date_trunc('month',current_date) as date) + gs.id -1 as start_date
from generate_series(1,32) gs(id)
where gs.id<=32;
start_date
------------
2012-12-01
2012-12-02
2012-12-03
2012-12-04
2012-12-05
2012-12-06
2012-12-07
2012-12-08
2012-12-09
2012-12-10
2012-12-11
2012-12-12
2012-12-13
2012-12-14
2012-12-15
2012-12-16
2012-12-17
2012-12-18
2012-12-19
2012-12-20
2012-12-21
2012-12-22
2012-12-23
2012-12-24
2012-12-25
2012-12-26
2012-12-27
2012-12-28
2012-12-29
2012-12-30
2012-12-31
2013-01-01
(32 rows)
scott@pg-00:5432:scottdb]
SQL>