Sequence in RAC

Problem:
I created a sequence of a DB in rac:
SQL> CREATE SEQUENCE PROVA_SEQ_OBJ
START WITH 2001
INCREMENT BY 1
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20;
Values ​​are not disconnected in sequence in the two nodes of the recommendations:
instance two:
 
SQL> SELECT USERENV(‘INSTANCE’) FROM DUAL;
USERENV(‘INSTANCE’)
——————-
2
SQL> SELECT PROVA_SEQ_OBJ .nextval from dual;
NEXTVAL
———-
2021
Instance one
SQL> SELECT USERENV(‘INSTANCE’) FROM DUAL;
USERENV(‘INSTANCE’)
——————-
1
SQL> SELECT PROVA_SEQ_OBJ. nextval from dual;
NEXTVAL
———-
2001
The solution is in this oracle note:
SEQUENCE:
ORDER Specify ORDER to guarantee that sequence numbers are generated in order of request.
This clause is useful if you are using the sequence numbers as timestamps.
Guaranteeing order is usually not important for sequences used to generate primary keys.
ORDER is necessary only to guarantee ordered generation if you are using Oracle Real Application Clusters.
If you are using exclusive mode, then sequence numbers are always generated in order.
If the parameter is not specified, the default oracle creates the sequence with the parameter noorder.
We then recreated the sequence with the clause ORDER:
SQL> CREATE SEQUENCE PROVA_SEQ_OBJ
START WITH 41
MAXVALUE 9999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
ORDER;
Now the values ​​are detached in sequence
SQL> SELECT USERENV(‘INSTANCE’) FROM DUAL;
SELECT PROVA_SEQ_OBJ.nextval from dual;
USERENV(‘INSTANCE’)
——————-
1
SQL>
NEXTVAL
———-
41
SELECT USERENV(‘INSTANCE’) FROM DUAL;
SELECT PROVA_SEQ_OBJ .nextval from dual;
USERENV(‘INSTANCE’)
——————-
2
NEXTVAL
———-
42
 
 

Potrebbero interessarti anche...