Previous |
Next |
Sequences are schema objects that generate unique sequential values, which are very useful when you need unique primary keys. The HR
schema has three sequences: DEPARTMENTS_SEQ
, EMPLOYEES_SEQ
, and LOCATIONS_SEQ
.
Sequences are used through the pseudocolumns CURRVAL
and NEXTVAL
, which return the current and next values of the sequence, respectively. After creating a sequence, you must initialize it by using NEXTVAL
to get its first value. Only after the sequence is initialized does CURRVAL
return its current value.
This section contains: