scalar-extension

lastval

Return the most recent nextval for any sequence in this session; fails if none has been called.

Formal Syntax & Structure

sql syntaxsql
lastval()

Working Example

Example Snippetsql
CREATE TEMP SEQUENCE bm_seq START 10; SELECT nextval('bm_seq'); SELECT lastval();
SQL Reference