Your browser does not support JavaScript. This help page requires JavaScript to render correctly. Creating and Managing Sequences
Skip Headers
Previous
Previous
 
Next
Next

Creating and Managing Sequences

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.


Tip:

When you plan to use a sequence to populate the primary key of a table, give the sequence a name that reflects this purpose. (This topic uses the naming convention table_name_SEQ.)

This section contains:

Related Topics

Oracle Database Concepts

Oracle Database SQL Language Reference

Editing Installation Script Files that Create Sequences

Creating and Managing Schema Objects