Oracle PL/SQL Tutorial/System Tables Data Dictionary/all sequences
Get information on all the sequences you have access to using all_sequences.
SQL>
SQL> desc all_sequences;
Name Null? Type
-----------------
SEQUENCE_OWNER NOT NULL VARCHAR2(30)
SEQUENCE_NAME NOT NULL VARCHAR2(30)
MIN_VALUE NUMBER
MAX_VALUE NUMBER
INCREMENT_BY NOT NULL NUMBER
CYCLE_FLAG VARCHAR2(1)
ORDER_FLAG VARCHAR2(1)
CACHE_SIZE NOT NULL NUMBER
LAST_NUMBER NOT NULL NUMBER
SQL> Null? Type
SQL> --select * from all_sequences;
Using a Sequence
- A sequence generates a series of numbers.
- A sequence contains two pseudo columns named currval and nextval.
- Before retrieving the current value you must initialize a sequence by retrieving the next value.
- When you select test_seq.nextval the sequence is initialized to 1.
SQL> CREATE SEQUENCE test_seq;
Sequence created.
SQL>
SQL> SELECT test_seq.nextval FROM dual;
NEXTVAL
----------
1
SQL>
SQL> drop sequence test_seq
2 /
Sequence dropped.