generate_series()

A system function for generating a series of values

generate_series() is a system function for generating a series of values (either numeric or time-based).

generate_series() was added in PostgreSQL 8.0.

Usage

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
generate_series ( start timestamp, stop timestamp, step interval ) → setof timestamp
generate_series ( start timestamp with time zone, stop timestamp with time zone, step interval ) → setof timestamp with time zone

Change history

Examples

Basic execution of generate_series():

postgres=# SELECT generate_series(1,5);
 generate_series 
-----------------
               1
               2
               3
               4
               5
(5 rows)

Categories

System function

See also

generate_subscripts()