本節描述可能傳回多筆資料集合的函數。 此類別中使用最廣泛的函數是數列生成函數,如 Table 9.65 和 Table 9.66 所示。 其他更詳細的集合回傳函數在本手冊的其他章節也有說明。有關組合多個集合回傳函數的方法,請參閱第 7.2.1.4 節。
When step
is positive, zero rows are returned if start
is greater than stop
. Conversely, when step
is negative, zero rows are returned if start
is less than stop
. Zero rows are also returned if any input is NULL
. It is an error for step
to be zero. Some examples follow:
generate_subscripts
is a convenience function that generates the set of valid subscripts for the specified dimension of the given array. Zero rows are returned for arrays that do not have the requested dimension, or if any input is NULL
. Some examples follow:
When a function in the FROM
clause is suffixed by WITH ORDINALITY
, a bigint
column is appended to the function's output column(s), which starts from 1 and increments by 1 for each row of the function's output. This is most useful in the case of set returning functions such as unnest()
.
Function
Description
generate_series
( start
integer
, stop
integer
[, step
integer
] ) → setof integer
generate_series
( start
bigint
, stop
bigint
[, step
bigint
] ) → setof bigint
generate_series
( start
numeric
, stop
numeric
[, step
numeric
] ) → setof numeric
產生從 start 到 stop 的一系列數值,間隔為 step,其預設為 1。
generate_series
( start
timestamp
, stop
timestamp
, step
interval
) → setof timestamp
generate_series
( start
timestamp with time zone
, stop
timestamp with time zone
, step
interval
[, timezone
text
] ) → setof timestamp with time zone
產生從 start 到 stop 的一系列數值,間隔為 step。在 with time zone 的時候,一天中的時間和夏令時調整是根據 timezone 參數指定的時區或目前 TimeZone 設定(如果省略的話)所計算的。
Function
Description
generate_subscripts
( array
anyarray
, dim
integer
) → setof integer
Generates a series comprising the valid subscripts of the dim
'th dimension of the given array.
generate_subscripts
( array
anyarray
, dim
integer
, reverse
boolean
) → setof integer
Generates a series comprising the valid subscripts of the dim
'th dimension of the given array. When reverse
is true, returns the series in reverse order.