select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / SET RETURNING FUNCTIONS

generate_series

Read PG 18 manual ↗

Generates a series of values from start to stop, with a step size of step.

Signatures & examples

generate_series ( start integer, stop integer [, step integer ] ) → setof integer
Generates a series of values from start to stop, with a step size of step. step defaults to 1.
generate_series ( start bigint, stop bigint [, step bigint ] ) → setof bigint
Generates a series of values from start to stop, with a step size of step. step defaults to 1.
generate_series ( start numeric, stop numeric [, step numeric ] ) → setof numeric
Generates a series of values from start to stop, with a step size of step. step defaults to 1.
generate_series ( start timestamp, stop timestamp, step interval ) → setof timestamp
Generates a series of values from start to stop, with a step size of step. In the timezone-aware form, times of day and daylight-savings adjustments are computed according to the time zone named by the timezone argument, or the current TimeZone setting if that is omitted.
generate_series ( start timestamp with time zone, stop timestamp with time zone, step interval [, timezone text ] ) → setof timestamp with time zone
Generates a series of values from start to stop, with a step size of step. In the timezone-aware form, times of day and daylight-savings adjustments are computed according to the time zone named by the timezone argument, or the current TimeZone setting if that is omitted.
Version history 3
  1. PG 15 → 16changed
  2. PG 12 → 13changed
  3. PG 9.4 → 9.5changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source