相信很多人都用过connect by生成数值列表,如下所示
SQL> select level from dual connect by level <= 10;
LEVEL
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected
如果没有connect by或不让用connect by语句怎么办呢
可以试下with语句
SQL> with x(a) as
2 (select 1 from dual union all select a + 1 from x where x.a < 10)
3 select * from x;
A
----------
1
2
3
4
5
6
7
8
9
10
10 rows selected