Skip to main content
Version: V1.0.0

CURRVAL(SEQ) function

The CURRVAL(SEQ) function returns the current value of a sequence.

Examples

To use CURRVAL, you must first create a sequence. The following example shows how to create a sequence and use CURRVAL.

Step 1: Create a sequence

CREATE SEQUENCE students_seq;

Step 2: Use NEXTVAL to insert new data

INSERT INTO students (id, name) VALUES (students_seq.NEXTVAL, 'John Doe');

Step 3: Use CURRVAL to get the current value

SELECT currval('students_seq');