↑↓ select↵ open⌫ change scopeOpen full search

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

Wiki / Functions

nextval

Advances the sequence object to its next value and returns that value. This is done atomically: even if multiple sessions execute nextval concurrently, each will safely receive a distinct sequence value. If the sequence object has been created with default parameters, successive nextval calls will return successive values beginning with 1. Other behaviors can be obtained by using appropriate parameters in the CREATE SEQUENCE command.

English manual coverage begins with PostgreSQL 7.1. Source history and runtime observations have their own recorded version boundaries.

Reading PG 18·Select a recorded version

group
sequence
group label
Sequence Manipulation Functions
lang
en
layout
table-new
pages
functions-sequence.html
prose only
false

Definition PG 18

Advances the sequence object to its next value and returns that value. This is done atomically: even if multiple sessions execute nextval concurrently, each will safely receive a distinct sequence value. If the sequence object has been created with default parameters, successive nextval calls will return successive values beginning with 1. Other behaviors can be obtained by using appropriate parameters in the CREATE SEQUENCE command.

Signatures and overloads

nextval ( regclass ) → bigint → bigint
Advances the sequence object to its next value and returns that value. This is done atomically: even if multiple sessions execute nextval concurrently, each will safely receive a distinct sequence value. If the sequence object has been created with default parameters, successive nextval calls will return successive values beginning with 1. Other behaviors can be obtained by using appropriate parameters in the CREATE SEQUENCE command.

Compare versions

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · wiki-repair-20261023:53ed757ad53cad4e5cb15cdd18a8bb0a5892ea536a83c297aa76a46738b2502f

Text language: en · wiki-repair-20261023:53ed757ad53cad4e5cb15cdd18a8bb0a5892ea536a83c297aa76a46738b2502f