Databases Reference
In-Depth Information
If all optional parameters are omitted, the sequence starts with one and
increases by increments of one, with no upper boundary.
Sequences are referenced in DML statements by using the syntax sequence_
name .currval or sequence_name .nextval. The qualifier nextval retrieves the
next value. The qualifier currval retrieves the most recent number generated
without incrementing the counter. For example, here are some sample SELECT
statements that access the sequence used for employee numbers, EMPLOYEES_SEQ:
select employees_seq.nextval from dual;
NEXTVAL
----------
211
1 row selected.
select employees_seq.nextval from dual;
NEXTVAL
----------
212
1 row selected.
select employees_seq.currval from dual;
CURRVAL
----------
212
1 row selected.
The HR department has asked the DBA, Janice, to re-create the sequence for
the EMPLOYEES table to start at 501 and increment by 10. Janice drops the old
sequence and re-creates it:
drop sequence hr.employees_seq;
Sequence dropped.
create sequence hr.employees_seq
start with 501
Search WWH ::




Custom Search