Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Sequences
12. Getting values from sequences
Summary

Instruction

Good. Once we create a sequence, we can use a special instruction to retrieve its next value. The code varies depending on the database. The standard syntax is:

SELECT NEXT VALUE FOR first_seq;

Unfortunately, the syntax above doesn't work in PostgreSQL, which is our database engine. We'll have to use another syntax:

SELECT nextval('first_seq');

The above code will select the next value for the sequence named first_seq.

Exercise

Select the next value for your new sequence my_sequence.

Stuck? Here's a hint!

Use a nextval() function.