Getting Information on Sequences : Sequence Information « Sequences « Oracle PL/SQL Tutorial






You get information on your sequences from user_sequences.

SQL> desc user_sequences;
 Name              Null?    Type
 ------------------
 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

last_number:Last number that was generated or cached by the sequence.

SQL>
SQL>
SQL> CREATE SEQUENCE test_seq
  2  START WITH 10 INCREMENT BY -1
  3  MINVALUE 1 MAXVALUE 10
  4  CYCLE CACHE 5;

Sequence created.

SQL>
SQL>
SQL> select * from user_sequences where sequence_name='TEST_SEQ';

SEQUENCE_NAME                   MIN_VALUE  MAX_VALUE INCREMENT_BY C O CACHE_SIZE LAST_NUMBER
------------------------------ ---------- ---------- ------------ - - ---------- -----------
TEST_SEQ                                1         10           -1 Y N          5          10

SQL>
SQL> drop sequence test_seq
  2  /

Sequence dropped.

SQL>








5.2.Sequence Information
5.2.1.Getting Information on Sequences
5.2.2.Get Sequence information from user_sequences table