Oracle PL/SQL Tutorial/System Tables Data Dictionary/all sequences

Материал из SQL эксперт
Перейти к: навигация, поиск

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

  1. A sequence generates a series of numbers.
  2. A sequence contains two pseudo columns named currval and nextval.
  3. Before retrieving the current value you must initialize a sequence by retrieving the next value.
  4. 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.