数据仓库服务 GAUSSDB(DWS)-序列号生成函数:generate_series(start, stop)

时间:2024-12-06 15:12:47

generate_series(start, stop)

描述:生成一个数值序列,从start到stop,步长默认为1。

参数类型:int、bigint、numeric

返回值类型:setof int、setof bigint、setof numeric(与参数类型相同)

示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
SELECT * FROM generate_series(2,4);
 generate_series
-----------------
               2
               3
               4
(3 rows)

SELECT * FROM generate_series(4,3);
 generate_series
-----------------
(0 rows)

SELECT * FROM generate_series(1,NULL);
 generate_series
-----------------
(0 rows)
support.huaweicloud.com/sqlreference-910-dws/dws_06_0336.html