Database Reference
In-Depth Information
A sequence is always accessed using the CURRVAL and NEXTVAL
pseudocolumns in the format as shown:
sequence.CURRVAL
. Returns the current value of the sequence.
The sequence is not incremented by the CURRVAL pseudocolumn.
sequence.NEXTVAL
. Returns the value of the sequence and
increases the sequence one increment. Usually, sequences increase by
increments of one each time; however, you can set a sequence to a dif-
ferent increment if needed.
22.1.1
Creating Sequences
A sequence can be created as shown in the syntax diagram in Figure 22.1.
Creating a sequence does not require any parameters other than the
sequence name. Executing the command shown as follows will create a
sequence called A_SEQUENCE in the current schema with an initial value
of zero and an incremental value of one. See the result of the following
commands in Figure 22.2.
CREATE SEQUENCE A_SEQUENCE;
SELECT A_SEQUENCE.NEXTVAL FROM DUAL;
Figure 22.1
CREATE
SEQUENCE
Syntax.
Search WWH ::




Custom Search