[One Moss per day]-[sequence]-continued-RAC and Sequences (853652.1) [one Moss per day]-RAC and Sequences (853652.1) http://www.bkjia.com/database/201308/239400.html what can be said of a simple sequence? If this is the case, it would be a big mistake... Some of the following high people may be very clear, but at least for me, they were unfamiliar or ignored. 1. create sequence seq; without any parameters, the default SQL statement is:
-- Create sequence create sequence SEQminvalue 1maxvalue 999999999999999999999999999start with 21increment by 1cache 20;
Start with is 21, increment by is 1, and cache is 20. Master Huang Yong explained that "Looks like the reverse-engineered sequence definition takes" start with "(1 by default) as" start with "value before the sequence is ever used, but takes "increment by" x "cache" + "start with" after it's used once or a few times. "Before the sequence is used, the sequence uses" start with (1 by default) "as the starting point. After one or several times of use, the sequence uses "increment by" x "cache and" start with "to count and take values. 2. The sequence definition, including the content seen from dba_sequences, is stored in the Data Dictionary of the Shared Pool. 3. The officially unpublished sys. v $ _ sequences table also records some sequence information, which is obtained from the Shared Pool. 4. The last_number field in dba_sequences refers to the high water level line or, more accurately, the maximum sequence value stored in the Shared Pool. 5. the cache sequence may be faulty because the cache value is purged. Operations such as flush shared pool may purge the cache. For example, when the Shared Pool is full and the new object (such as SQL) comes again, the old object will be aged out or the ASSM used, buffer cache requires more SGA space, so shrink has a Shared Pool. The fault may occur due to ROLLBACK. The PMON process is cleaned up. Metadata replaces the row cache (that is, Data Dictionary ). The instance is closed. Example:
SQL> create sequence seq_1;Sequence created.SQL> select seq_1.currval from dual;select seq_1.currval from dual *ERROR at line 1:ORA-08002: sequence SEQ_1.CURRVAL is not yet defined in this sessionSQL> select seq_1.nextval from dual; NEXTVAL---------- 1SQL> select seq_1.nextval from dual; NEXTVAL---------- 2...SQL> select seq_1.nextval from dual; NEXTVAL---------- 20SQL> SELECT last_number FROM dba_sequences WHERE sequence_name='SEQ_1';LAST_NUMBER----------- 21