Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Sequences
Summary
14. Summary

Instruction

It's time to wrap things up for this part! First, let's review:

  1. If you want to generate values for an integer column automatically and you never want to insert your own values, use:
    column_name integer GENERATED ALWAYS AS IDENTITY
  2. If you want to generate values for an integer column automatically but you will also sometimes insert your own values, use:
    column_name integer GENERATED BY DEFAULT AS IDENTITY
  3. To start generating from 5 and increment the counter by 10 each time, use:
    column_name integer GENERATED ALWAYS AS IDENTITY (START WITH 5 INCREMENT BY 10)
  4. To create a sequence, use:
    CREATE SEQUENCE first_seq START WITH 1 INCREMENT BY 1;
  5. To retrieve the next value from a sequence in PostgreSQL, use:
    nextval('first_seq')

All right, how about a short quiz?

Exercise

Click Next exercise to continue.