Saturday, November 16, 2013

12c New Features: Session Scope Sequence

SQL> create sequence s1 start with 1 increment by 1;

Sequence created.

SQL> create sequence s2 start with 1 increment by 1 session;

Sequence created.

SQL> select sequence_name,session_flag,keep_value from user_sequences
  2  where sequence_name in ('S1','S2');

SEQUENCE_NAME        S K
-------------------- - -
S1                   N N
S2                   Y N


SQL> select s1.nextval from dual;

   NEXTVAL
----------
         1

SQL>  select s2.nextval from dual;

   NEXTVAL
----------
         1

SQL> conn donghua/donghua
Connected.
SQL> select s1.nextval from dual;

   NEXTVAL
----------
         2

SQL> select s2.nextval from dual;

   NEXTVAL
----------
         1

SQL>

No comments:

Post a Comment