Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Defining columns with DEFAULT
7. DEFAULT and sequences – 2
Adding DEFAULT to existing tables
Summary

Instruction

Good! The first step is done. Let's proceed.

Exercise

To get the next value of the sequence my_sequence in PostgreSQL we use the expression:

nextval('my_sequence')

Now, change the template we provided. We don't want the DEFAULT value of id to be 1. Replace it with the next value of the sequence id_seq.

Remember that the standard SQL syntax is a little different:

NEXT VALUE FOR my_sequence

In this course we use the PostgreSQL syntax.