It's Autumn! Prices fall like leaves! - hours only!Up to 80% off on all courses and bundles.-Close
Primary keys - the basics
Single-column primary keys
Multicolumn primary keys
Auto-increment columns and sequences
Revision

Instruction

Good. Once we create a sequence, we can use a special instruction to retrieve the next value for it. The code varies depending on the database, so don't worry if it's different from the one we presented below.

SELECT nextval('first_seq');

The above code will select the next value for the sequence named first_seq. It is possible to associate a sequence with values in a column, but we'll discuss it in another part of our course. For now, just remember what sequences are.

Exercise

Select the next value for your new sequence my_sequence.

Stuck? Here's a hint!

Type

SELECT nextval('my_sequence');