Get the App
SLTechnology News&Howtos  ›  Database  › 

The use of RAC_Sequence serial number

Shulou Source: shulou.com Published: 2022-06-01 07:12:58 09月20日 Update

[CACHE integer |NOCACHE] --Specifies the number of sequence values pre-allocated in database memory, with a minimum cache value of 2| Do not specify cache count

The default value is cache 20.

[ORDER |NOORDER] --Specify an order condition to ensure that the sequence is generated in the order requested| There is no guarantee that the sequence will be generated in the order requested

Default is NOORDER

Single sequence is order. Even if you add noorder, the result is still order.

RAC sequence has real order and noorder

Order: Two nodes maintain the same order

noorder: If nocache is used, both nodes remain in the same order

If cache is used, the two nodes are not ordered, but each node is internally ordered.

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB2

SQL> create sequence SEQ_T1 start with 10 maxvalue 100000 cache 2000 noorder;

Sequence created.

SQL> select SEQ_T1.nextval from dual;

NEXTVAL

----------

10

SQL> select SEQ_T1.nextval from dual;

NEXTVAL

----------

11

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB1

SQL> select SEQ_T1.nextval from dual;

NEXTVAL

----------

2010

SQL> select SEQ_T1.nextval from dual;

NEXTVAL

----------

2011

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB2

SQL> create sequence SEQ_T2 start with 10 maxvalue 100000 nocache noorder;

Sequence created.

SQL> select SEQ_T2.nextval from dual;

NEXTVAL

----------

10

SQL> select SEQ_T2.nextval from dual;

NEXTVAL

----------

11

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB1

SQL> select SEQ_T2.nextval from dual;

NEXTVAL

----------

12

SQL> select SEQ_T2.nextval from dual;

NEXTVAL

----------

13

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB2

SQL> create sequence SEQ_T3 start with 10 maxvalue 100000 noorder;

Sequence created.

SQL> select SEQ_T3.nextval from dual;

NEXTVAL

----------

10

SQL> select SEQ_T3.nextval from dual;

NEXTVAL

----------

11

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB1

SQL> select SEQ_T3.nextval from dual;

NEXTVAL

----------

30

SQL> select SEQ_T3.nextval from dual;

NEXTVAL

----------

31

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB2

SQL> create sequence SEQ_T4 start with 10 maxvalue 100000 order;

Sequence created.

SQL> select SEQ_T4.nextval from dual;

NEXTVAL

----------

10

SQL> select SEQ_T4.nextval from dual;

NEXTVAL

----------

11

SQL> show parameter instance_name

NAME TYPE VALUE

------------------------------------ ----------- ------------------------------

instance_name string PLMDB1

SQL> select SEQ_T4.nextval from dual;

NEXTVAL

----------

12

SQL> select SEQ_T4.nextval from dual;

NEXTVAL

----------

13

Tags: Node sequence two order guarantee generate minimum number memory stand-alone data database condition result cache or allocation serial number Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Tech Info macOS vpn MariaDB