手動重新整理share pool導致快取序列(cache sequence)不連續/丟失
阿新 • • 發佈:2018-12-30
手動重新整理share pool可導致快取序列(cache sequence)不連續/丟失,
dbms_shared_pool.keep可防止sequence cache不被flush share pool清空,
但是不能防止shutdown引起sequence cache清空而導致的sequence斷裂。
C:\>sqlplus scott/[email protected]
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 8 18:34:35 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> drop sequence test_seq;
Sequence dropped.
SQL> CREATE SEQUENCE test_seq START WITH 10000 MAXVALUE 2147483647 MINVALUE 1 NOCYCLE CACHE 1000 NOORDER;
Sequence created.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
10000
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
10001
SQL> alter system flush shared_pool;
System altered.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11000
SQL> execute sys.dbms_shared_pool.keep('test_seq', 'Q');
PL/SQL procedure successfully completed.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11001
SQL> alter system flush shared_pool;
System altered.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11002
SQL>
REF:
Caching Oracle Sequences [ID 62002.1]
dbms_shared_pool.keep可防止sequence cache不被flush share pool清空,
但是不能防止shutdown引起sequence cache清空而導致的sequence斷裂。
C:\>sqlplus scott/[email protected]
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jun 8 18:34:35 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> drop sequence test_seq;
Sequence dropped.
SQL> CREATE SEQUENCE test_seq START WITH 10000 MAXVALUE 2147483647 MINVALUE 1 NOCYCLE CACHE 1000 NOORDER;
Sequence created.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
10000
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
10001
SQL> alter system flush shared_pool;
System altered.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11000
SQL> execute sys.dbms_shared_pool.keep('test_seq', 'Q');
PL/SQL procedure successfully completed.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11001
SQL> alter system flush shared_pool;
System altered.
SQL> select test_seq.nextval from dual;
NEXTVAL
----------
11002
SQL>
REF:
Caching Oracle Sequences [ID 62002.1]